home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / dbimprtx / _setup.1 / frmTest.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-12-31  |  4.8 KB  |  158 lines

  1. VERSION 5.00
  2. Object = "*\A..\PrjDBImport.vbp"
  3. Begin VB.Form frmTest 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "DBImport Demo"
  6.    ClientHeight    =   3825
  7.    ClientLeft      =   2835
  8.    ClientTop       =   2490
  9.    ClientWidth     =   4245
  10.    Icon            =   "frmTest.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3825
  15.    ScaleWidth      =   4245
  16.    Begin DBImportActiveX.DBImport DBImport1 
  17.       Height          =   345
  18.       Left            =   1890
  19.       TabIndex        =   7
  20.       Top             =   3300
  21.       Visible         =   0   'False
  22.       Width           =   300
  23.       _ExtentX        =   529
  24.       _ExtentY        =   609
  25.    End
  26.    Begin VB.ComboBox Combo1 
  27.       Height          =   315
  28.       ItemData        =   "frmTest.frx":030A
  29.       Left            =   2250
  30.       List            =   "frmTest.frx":031A
  31.       Style           =   2  'Dropdown List
  32.       TabIndex        =   3
  33.       Top             =   2880
  34.       Width           =   1905
  35.    End
  36.    Begin VB.DriveListBox Drive1 
  37.       Height          =   315
  38.       Left            =   120
  39.       TabIndex        =   2
  40.       Top             =   2880
  41.       Width           =   1905
  42.    End
  43.    Begin VB.FileListBox File1 
  44.       Height          =   2040
  45.       Left            =   2220
  46.       Pattern         =   "*.MDB"
  47.       TabIndex        =   1
  48.       Top             =   630
  49.       Width           =   1932
  50.    End
  51.    Begin VB.CommandButton Command2 
  52.       Cancel          =   -1  'True
  53.       Caption         =   "Close"
  54.       Height          =   375
  55.       Left            =   480
  56.       TabIndex        =   4
  57.       Top             =   3330
  58.       Width           =   1335
  59.    End
  60.    Begin VB.DirListBox Dir1 
  61.       Height          =   2115
  62.       Left            =   108
  63.       TabIndex        =   0
  64.       Top             =   630
  65.       Width           =   1935
  66.    End
  67.    Begin VB.CommandButton cmdImport 
  68.       Caption         =   "Import"
  69.       Height          =   375
  70.       Left            =   2460
  71.       TabIndex        =   6
  72.       Top             =   3330
  73.       Width           =   1335
  74.    End
  75.    Begin VB.Label Label1 
  76.       Caption         =   "Select any Table to which you want to import data, and click on 'Import'"
  77.       Height          =   435
  78.       Left            =   120
  79.       TabIndex        =   5
  80.       Top             =   120
  81.       Width           =   3990
  82.    End
  83. Attribute VB_Name = "frmTest"
  84. Attribute VB_GlobalNameSpace = False
  85. Attribute VB_Creatable = False
  86. Attribute VB_PredeclaredId = True
  87. Attribute VB_Exposed = False
  88. Option Explicit
  89. Dim connect As TypeConnect
  90. Sub import()
  91.     ' DBImport1.MultiTable = True
  92.     Select Case Combo1.ListIndex
  93.     Case 0 ' access database : let the user choose the table to export (MultiTable=True)
  94.          DBImport1.DatabaseName = Dir1.Path & "\" & File1.filename
  95.     Case 1, 2 ' PDox or DBase, export one table at a time (MultiTable=False)
  96.          DBImport1.DatabaseName = Dir1.Path
  97.          DBImport1.TableName = File1.filename
  98.     Case Else 'ODBC
  99.          frmODBCLogon.Show vbModal
  100.          If frmODBCLogon.bOk Then
  101.             DBImport1.DSN = frmODBCLogon.cboDSNList.Text
  102.             DBImport1.UserName = frmODBCLogon.txtUID
  103.             DBImport1.Password = frmODBCLogon.txtPWD
  104.             DBImport1.DatabaseName = frmODBCLogon.txtDatabase
  105.          Else
  106.             Exit Sub
  107.          End If
  108.     End Select
  109.     DBImport1.ConnectString = connect
  110.     DBImport1.IniFile = App.Path & "\ExportSettings.ini"
  111.     DBImport1.Execute
  112. End Sub
  113. Private Sub cmdImport_Click()
  114.     import
  115. End Sub
  116. Private Sub Combo1_Click()
  117.     Select Case Combo1.ListIndex
  118.     Case 0
  119.         File1.Pattern = "*.MDB"
  120.         connect = Access
  121.     Case 1
  122.         File1.Pattern = "*.DB"
  123.         connect = Paradox5
  124.     Case 2
  125.         File1.Pattern = "*.DBF"
  126.         connect = DBase5
  127.     Case 3
  128.         connect = ODBC
  129.     End Select
  130. End Sub
  131. Private Sub Command1_Click()
  132. End Sub
  133. Private Sub Command2_Click()
  134.     Unload Me
  135. End Sub
  136. Private Sub DBImport1_BeforeFieldImport(ByVal TableName As String, ByVal FieldName As String, ByVal FieldType As Integer, ByVal FieldSize As Integer, bufField As String)
  137.     If FieldName = "Fax" And bufField = "" Then bufField = "00.00.00.00.00"
  138. End Sub
  139. Private Sub Dir1_Change()
  140.     File1.Path = Dir1.Path  ' Set file path.
  141. End Sub
  142. Private Sub Drive1_Change()
  143.     Dir1.Path = Drive1.Drive    ' Set directory path.
  144. End Sub
  145. Private Sub File1_DblClick()
  146.     import
  147. End Sub
  148. Private Sub Form_Load()
  149.     Dim iTop%, iLeft%
  150.     Combo1.ListIndex = 0
  151.     ' Center the Form
  152.     iTop = (Screen.Height - Height) \ 2
  153.     If iTop < 0 Then iTop = 0
  154.     iLeft = (Screen.Width - Width) \ 2
  155.     If iLeft < 0 Then iLeft = 0
  156.     Move iLeft, iTop
  157. End Sub
  158.