Results 1 to 10 of 10
  1. #1
    usmcgrunt's Avatar
    usmcgrunt is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Just outside the gates of freedom
    Posts
    71

    Executing Simulated Form Progress Bar on Form Open (Teaching Myself VBA)

    Bear with me if I use the wrong terms.

    I am trying to wrap my head around how I can execute a series of events within one function or block of code and have a delay/pause in between each.

    I have successfully been able to accomplish this by attaching the code to a button on a form but what I really want is for the code to execute when the form opens/loads/activates (don't know which one is appropriate).

    Right now if I attach the code to the form load or open event, the code executes and then the form opens; bottom line: the user does not get to see the code execute.

    Here is the code I currently have in my form. I also attached a link to a sample db that contains the form in question.
    -------------------------------------------------------------------------
    ' ************************************************** **
    ' This is the pause function in between each of the progress bar
    ' increments and the text that changes during the progress bar load
    '
    ' Credit for this function goes to ghudson
    ' from http://www.access-programmers.co.uk/...ad.php?t=94302
    ' ************************************************** **

    Public Function Pause(NumberOfSeconds As Variant)
    On Error GoTo Err_Pause

    Dim PauseTime As Variant, Start As Variant

    PauseTime = NumberOfSeconds
    Start = Timer
    Do While Timer < Start + PauseTime
    DoEvents
    Loop

    Exit_Pause:
    Exit Function

    Err_Pause:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Pause

    End Function
    -----------------------------------------------------------------------

    ' *************************************************
    ' This is the the actual code for the progress bar and progress text
    ' *************************************************

    Private Sub progressBar_Click()

    If Me.lbl1.Visible = False Then
    Me.lblProgress.Caption = "Verifying Username......"


    Pause (0.5)
    Me.lbl1.Visible = True
    Pause (0.5)
    Me.lbl2.Visible = True
    Pause (0.5)
    Me.lblProgress.Caption = "Verifying password......"
    Pause (0.5)
    Me.lbl3.Visible = True
    Pause (0.5)
    Me.lbl4.Visible = True
    Pause (0.5)
    Me.lblProgress.Caption = "Verifying database rights......"
    Pause (0.75)
    Me.lbl5.Visible = True
    Pause (0.75)
    Me.lbl6.Visible = True
    Pause (0.75)
    Me.lblProgress.Caption = "Setting user database rights......"
    Pause (0.75)
    Me.lbl7.Visible = True
    Pause (0.75)
    Me.lbl8.Visible = True
    Pause (0.75)
    Me.lbl9.Visible = True
    Pause (0.5)
    Me.lblProgress.Caption = "User Validated... Loading Main Menu"
    Pause (0.5)
    Me.lbl10.Visible = True
    Pause (0.5)
    DoCmd.Close acForm, "FrmSplashScreen"
    DoCmd.OpenForm "Switchboard", acNormal
    Else
    DoCmd.Close acForm, "FrmSplashScreen"
    End If

    End Sub


    Suggestions?

    Sean

    http://www.mediafire.com/?gh12fd8dd59ks7u

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Try using the timer event of the form, with a small interval. The form should fully load before the timer event fires. In your code, set the timer interval to 0 so it only runs once.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Stick it inder the timer event that is preset to maybe 3 seconds (3000). Being very event driven there are not a lot of events on a static form.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Oops...Paul posted while I was composing. I hate it when that happens!

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    However...Great minds...

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Great minds think alike...and sometimes mine does too!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    usmcgrunt's Avatar
    usmcgrunt is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Just outside the gates of freedom
    Posts
    71
    Paul & Allen, credit to you both. That did it. So here is my understanding of what the code actual did:

    1. Setting a Me.TimeInterval in the Form_Open allowed the form to open before the Form_Timer event trigger. Yes or No?

    2. Since the form in question is unbound the TimeInterval can be very short but if the form was loading a significant amount of records I would then need to extend the TimeInterval?

    Thanks again. Thread SOLVED!!!!!!!!!!!!!
    to both of you.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm giving Paul the beer on this one. I've already had too much tonight, but thanks.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    1) Not really sure, but I don't think you need to set the timer interval in the open event. I would probably just set it in design view (of course, there's always the theory that if it ain't broke...).

    2) Again, not really sure, but my gut is that you could use a short interval either way. I don't think Access will start the timer until the form finishes loading. It would be an interesting test if you have a form that takes a bit to load.

    I haven't had any beer yet tonight, so thanks!!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would also just set the interval in design view and as you already said, reset the interval to zero in the beginning of the interrupt to stop the timer. The #2 test would be a useful thing to learn. I passed on a very dark beer. I hope you like it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-16-2010, 09:50 AM
  2. Open form on update of field in another form.
    By thekruser in forum Forms
    Replies: 5
    Last Post: 09-13-2010, 02:12 PM
  3. Open Form with information from previous form
    By jheintz57 in forum Forms
    Replies: 9
    Last Post: 03-23-2010, 07:30 AM
  4. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  5. In a field on a Form, on click open another form
    By jackieagra in forum Programming
    Replies: 1
    Last Post: 03-20-2008, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums