home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / VISDATA / NEWATTCH.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-03-12  |  6.9 KB  |  239 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNewAttach 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "
  5.    ClientHeight    =   3465
  6.    ClientLeft      =   4830
  7.    ClientTop       =   5325
  8.    ClientWidth     =   4245
  9.    HelpContextID   =   2016135
  10.    Icon            =   "NEWATTCH.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3465
  16.    ScaleWidth      =   4245
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   1  'CenterOwner
  19.    Begin VB.ComboBox cboConnect 
  20.       Height          =   315
  21.       ItemData        =   "NEWATTCH.frx":030A
  22.       Left            =   120
  23.       List            =   "NEWATTCH.frx":030C
  24.       TabIndex        =   5
  25.       Top             =   1560
  26.       Width           =   3975
  27.    End
  28.    Begin VB.TextBox txtDatabase 
  29.       Height          =   285
  30.       Left            =   120
  31.       TabIndex        =   3
  32.       Top             =   960
  33.       Width           =   3975
  34.    End
  35.    Begin VB.CheckBox chkExclusive 
  36.       Caption         =   "
  37.       Height          =   225
  38.       Left            =   2160
  39.       MaskColor       =   &H00000000&
  40.       TabIndex        =   9
  41.       Top             =   2520
  42.       Width           =   1785
  43.    End
  44.    Begin VB.CheckBox chkSavePassword 
  45.       Caption         =   "
  46.       Height          =   225
  47.       Left            =   120
  48.       MaskColor       =   &H00000000&
  49.       TabIndex        =   8
  50.       Top             =   2520
  51.       Width           =   1740
  52.    End
  53.    Begin VB.CommandButton cmdCancel 
  54.       Cancel          =   -1  'True
  55.       Caption         =   "
  56. (&C)"
  57.       Height          =   435
  58.       Left            =   2160
  59.       MaskColor       =   &H00000000&
  60.       TabIndex        =   11
  61.       Top             =   2880
  62.       Width           =   1905
  63.    End
  64.    Begin VB.CommandButton cmdAttach 
  65.       Caption         =   "
  66. (&A)"
  67.       Default         =   -1  'True
  68.       Enabled         =   0   'False
  69.       Height          =   435
  70.       Left            =   120
  71.       MaskColor       =   &H00000000&
  72.       TabIndex        =   10
  73.       Top             =   2880
  74.       Width           =   1905
  75.    End
  76.    Begin VB.ComboBox cboTableName 
  77.       Height          =   315
  78.       Left            =   120
  79.       TabIndex        =   7
  80.       Top             =   2160
  81.       Width           =   3975
  82.    End
  83.    Begin VB.TextBox txtAttachName 
  84.       Height          =   285
  85.       Left            =   120
  86.       TabIndex        =   1
  87.       Top             =   360
  88.       Width           =   3975
  89.    End
  90.    Begin VB.Label lblLabels 
  91.       AutoSize        =   -1  'True
  92.       Caption         =   "
  93.       Height          =   195
  94.       Index           =   1
  95.       Left            =   105
  96.       TabIndex        =   2
  97.       Top             =   720
  98.       Width           =   1245
  99.    End
  100.    Begin VB.Label lblLabels 
  101.       AutoSize        =   -1  'True
  102.       Caption         =   "
  103.       Height          =   195
  104.       Index           =   3
  105.       Left            =   120
  106.       TabIndex        =   6
  107.       Top             =   1920
  108.       Width           =   1215
  109.    End
  110.    Begin VB.Label lblLabels 
  111.       AutoSize        =   -1  'True
  112.       Caption         =   "
  113.       Height          =   195
  114.       Index           =   2
  115.       Left            =   105
  116.       TabIndex        =   4
  117.       Top             =   1320
  118.       Width           =   1170
  119.    End
  120.    Begin VB.Label lblLabels 
  121.       AutoSize        =   -1  'True
  122.       Caption         =   "
  123.       Height          =   195
  124.       Index           =   0
  125.       Left            =   120
  126.       TabIndex        =   0
  127.       Top             =   105
  128.       Width           =   1395
  129.    End
  130. Attribute VB_Name = "frmNewAttach"
  131. Attribute VB_GlobalNameSpace = False
  132. Attribute VB_Creatable = False
  133. Attribute VB_PredeclaredId = True
  134. Attribute VB_Exposed = False
  135. Option Explicit
  136. '>>>>>>>>>>>>>>>>>>>>>>>>
  137. Const FORMCAPTION = "
  138. Const BUTTON1 = "
  139. (&A)"
  140. Const BUTTON2 = "
  141. (&C)"
  142. Const Label1 = "
  143. Const Label2 = "
  144. Const LABEL3 = "
  145. Const LABEL4 = "
  146. Const CHECK1 = "
  147. (&P)"
  148. Const CHECK2 = "
  149. (&E)"
  150. '>>>>>>>>>>>>>>>>>>>>>>>>
  151. Dim mbAdded As Boolean
  152. Private Sub cmdCancel_Click()
  153.   If mbAdded Then
  154.     '
  155.     RefreshTables Nothing
  156.   End If
  157.   Unload Me
  158. End Sub
  159. Sub Form_Load()
  160.   Me.Caption = FORMCAPTION
  161.   cmdAttach.Caption = BUTTON1
  162.   cmdCancel.Caption = BUTTON2
  163.   lblLabels(0).Caption = Label1
  164.   lblLabels(1).Caption = Label2
  165.   lblLabels(2).Caption = LABEL3
  166.   lblLabels(3).Caption = LABEL4
  167.   chkSavePassword.Caption = CHECK1
  168.   chkExclusive.Caption = CHECK2
  169.   cboConnect.AddItem "Access MDB"
  170.   cboConnect.AddItem "Dbase III"
  171.   cboConnect.AddItem "Dbase IV"
  172.   cboConnect.AddItem "FoxPro 2.0"
  173.   cboConnect.AddItem "FoxPro 2.5"
  174.   cboConnect.AddItem "FoxPro 2.6"
  175.   cboConnect.AddItem "Paradox 3.X"
  176.   cboConnect.AddItem "Paradox 4.X"
  177.   cboConnect.AddItem "Excel 5.0"
  178.   cboConnect.AddItem "Excel 4.0"
  179.   cboConnect.AddItem "Excel 3.0"
  180.   cboConnect.AddItem "Text"
  181.   cboConnect.AddItem "ODBC"
  182.   cboConnect.ListIndex = 0
  183. End Sub
  184. Private Sub txtAttachName_Change()
  185.   cmdAttach.Enabled = Len(txtAttachName.Text) > 0
  186.   If cboTableName.ListCount > 0 Then cboTableName.Clear
  187. End Sub
  188. Private Sub cboConnect_Change()
  189.   cmdAttach.Enabled = Len(txtAttachName.Text) > 0
  190.   If cboTableName.ListCount > 0 Then cboTableName.Clear
  191. End Sub
  192. Private Sub cboTableName_DropDown()
  193.   Dim db As Database
  194.   Dim i As Integer
  195.   Dim sDataType As String       '
  196.   Dim tdf As TableDef
  197.   On Error GoTo DDErr
  198.   Screen.MousePointer = vbHourglass
  199.   If cboTableName.ListCount = 0 Then
  200.     '
  201.     sDataType = GetConnectStr()
  202.     If cboConnect.ListIndex = 0 Then
  203.       'Microsoft Access mdb 
  204.       Set db = gwsMainWS.OpenDatabase(vbNullString, 0, 0, sDataType)
  205.     Else
  206.       Set db = gwsMainWS.OpenDatabase(vbNullString, 0, 0, sDataType & ";" & cboConnect.Text)
  207.     End If
  208.     For Each tdf In db.TableDefs
  209.       If (tdf.Attributes And dbSystemObject) = 0 Then
  210.         cboTableName.AddItem tdf.Name
  211.       End If
  212.     Next
  213.   End If
  214.   Screen.MousePointer = vbDefault
  215.   Exit Sub
  216. DDErr:
  217.   ShowError
  218. End Sub
  219. Private Sub cmdAttach_Click()
  220.   frmAttachments.AddAttachment
  221.   mbAdded = True
  222. End Sub
  223. Public Function GetConnectStr() As String
  224.   On Error GoTo GCErr
  225.   Dim sTmp As String
  226.   If cboConnect.ListIndex = 0 Then
  227.     sTmp = ";"
  228.   Else
  229.     sTmp = cboConnect.Text & ";"
  230.   End If
  231.   If Len(txtDatabase.Text) > 0 Then
  232.     sTmp = sTmp & "database=" & txtDatabase
  233.   End If
  234.   GetConnectStr = sTmp
  235.   Exit Function
  236. GCErr:
  237.   ShowError
  238. End Function
  239.