Results 1 to 5 of 5

Thread: Pause for user interaction

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    15

    Angry

    How can I get the code to pause long enough for the user to change criteria in an access query before the next line of code runs?

    ' Opens BestTrafficBuildingClass JB query in Design view
    DoCmd.OpenQuery "BestTrafficBuildingClass JB", acDesign, acEdit

    ' Basic message to user
    MsgBox "Please change the event code to reflect the current period.", vbInformation, "Change Event Code"

    ' How do I pause the code here so the user can change the event code before the remaining code runs?


    ' Opens BestTrafficBuildingClass KY query in Design view
    DoCmd.OpenQuery "BestTrafficBuildingClass KY", acDesign, acEdit


    Thanks for any ideas!!!!
    Confused

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Smile What are they using to change the data?

    Use something like this:
    Dim X as integer in the Declarations
    Code:
    Do Until X = 1
       DoEvents
    Loop
    X = 0 'reset X
    The Set X = 1 when the user click or type or does what they are supposed to do.
    like this

    Say the have to type in a text box...maybe look for then Enter key to be struck then X = 1...
    or add a command button that enters/changes the data then sets X = 1...so on..

    Just make sure that X = 1 is the LAST thing your code does...(if you set X = 1 then do code it will continue while the other code is trying to complete)

    Hope this helps

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    15
    O.K I know I am new to VB and totally confused but when I added the code as follows I am in an endless loop. What did I do wrong?

    Function Test()
    On Error GoTo Test_Err

    Dim X As Integer

    ' Opens Access Query in design view
    DoCmd.OpenQuery "BestTrafficBuildingClass JB", acDesign, acEdit

    ' Basic message box
    MsgBox "Please change the event code to reflect the current period.", vbInformation, "Change Event Code"

    'Opens next Access Query in design view
    DoCmd.OpenQuery "BestTrafficBuildingClass KY", acDesign, acEdit

    ' Basic message box
    MsgBox "Please change the event code to reflect the current period.", vbInformation, "Change Event Code"
    Loop

    'resets X
    X = 0

    Test_Exit:
    Exit Function

    Test_Err:
    MsgBox Error$
    Resume Test_Exit

    End Function
    Confused

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Unhappy hmmm

    Code:
    Function Test() 
    On Error GoTo Test_Err 
    
    Dim X As Integer 'GET THIS INTO THE General Declarations Section
    
    
    ' Opens Access Query in design view 
    DoCmd.OpenQuery "BestTrafficBuildingClass JB", acDesign, acEdit 
    
    ' Basic message box 
    MsgBox "Please change the event code to reflect the current period.", vbInformation, "Change Event Code" 
    'You want it to wait here?
    Do until X = 1
     DoEvents
    Loop
    X = 0
    
    
    'Opens next Access Query in design view 
    DoCmd.OpenQuery "BestTrafficBuildingClass KY", acDesign, acEdit 
    
    ' Basic message box 
    MsgBox "Please change the event code to reflect the current period.", vbInformation, "Change Event Code" 
    
    'You want it to wait here?
    Do until X = 1
     DoEvents
    Loop
    X = 0
    
    
    Loop ' Whats this for? Where is the Do for this loop?
    
    'resets X 
    X = 0 ' Get rid of this here
    
    Test_Exit: 
    Exit Function 
    
    Test_Err: 
    MsgBox Error$ 
    Resume Test_Exit 
    
    End Function
    It's hard to pull this out of context...When the user is asked to chage data...what type of control is being used? A TextBox? Another form?

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    15
    Thanks! One more question. When the users makes change for the first access query why doesn't the code open the next access query?
    Confused

Posting Permissions

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



Click Here to Expand Forum to Full Width