I would like a Progress Bar on my form which basically mimics the progress bar in the status bar. I have a form which is importing a Text file using a specification. I'm using the progress bar ActiveX Object from MSCOMCTL.OCX
Since I am using TransferText, how can I set the progress bar to
a) advance properly
b) recognize what the max is
Code below WITH NO PROGRESS BAR... JUST SOME TEXT:
Private Sub cmdImport_Click()
Dim strTable As String
Dim strFileName As String
Dim intLen As Integer
Dim strFile As String
Dim dtFile As Date
Dim rst As Recordset
Dim intCount As Integer
Dim strSQLDate As String
Dim strSQLInsert As String
If (IsNull(txtFileOpen.Value) Or txtFileOpen.Value = "") Then
MsgBox "You must have a File specified to Import.", vbCritical, "Error Importing File"
lblProgress.Caption = "Error - No File Specified"
strFileName = txtFileOpen.Value
If (IsNull(txtTable.Value) Or txtTable.Value = "") Then
MsgBox "You must have a Table Name to Import the File to.", vbCritical, "Error Importing File"
lblProgress.Caption = "Error - No Table Name"
strTable = txtTable.Value
lblProgress.Visible = True
lblProgress.Caption = "Importing Dun and Bradstreet Data. Use Ctrl-Break to stop Import"
On Error Resume Next
DoCmd.RunSQL "DROP TABLE " & strTable
DoCmd.TransferText acImportFixed, "DNB Import Specification", strTable, strFileName
lblProgress.Caption = "Import Process Completed."
If you previously know the size of what you are importing then perhaps through a OnTimer event you can read the quantity received and advance your progress bar this way. Problem may be though that the TransferText function might not release to the timer.
It must be possible... since the current status bar has a progress bar which works properly. I believe I can get the number of records in the text file using a windows call - but I've no idea how to calculate the time it will take to import the file, or how to advance it properly.
That's interesting... they made their own. I still have the same problem though... don't know how to 'progress' it. Thanks, though!!!! This may be the way to go rather than relying on ActiveX components!