Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2003
    Location
    Greenwood, IN
    Posts
    40

    Angry Progress Bar and Transfertext VBA

    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"
    txtFileOpen.SetFocus
    Exit Sub
    End If

    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"
    txtTable.SetFocus
    Exit Sub
    End If

    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."
    End Sub
    Doug

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    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.

  3. #3
    Join Date
    Dec 2003
    Location
    Greenwood, IN
    Posts
    40

    It must be possible...

    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.
    Doug

  4. #4
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111

    Re: Progress Bar and Transfertext VBA

    I found this sometime ago...

    It's only a progress bar that works.

    All you need is to put your code in the middle of the execution...

    I don't know if this helps or not, but it's a simple and little prog.

    Ruas
    Attached Files Attached Files

  5. #5
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111

    Progress Bar

    See if this can help you...
    Attached Files Attached Files

  6. #6
    Join Date
    Dec 2003
    Location
    Greenwood, IN
    Posts
    40

    Invalid archive error

    Could you email it to me? doug @ coders4hire.com
    Doug

  7. #7
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111
    I'm sorry... I see just now there are two mess from me.

    The first time I had an error report sending the mess and the same in the second try... And they are here!!!

    I'll send you just now

    Ruas

  8. #8
    Join Date
    Dec 2003
    Location
    Greenwood, IN
    Posts
    40
    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!
    Doug

  9. #9
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111
    Let me suggest the following:

    create a counter

    Dim x
    For x = 1 to 500
    [create a field form named, by ex., n]
    Me.n = x
    Next

    and see both working.

    Try to put the code in the middle of the other...

    Yes, that's nice because there is no need of add-ins or activeX

  10. #10
    Join Date
    Aug 2012
    Location
    Heredia, Costa Rica
    Posts
    4
    jmruas the attached DB is not opening in WinZip. can you re-attach? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •