Tougher Question: Pausing Code/Goto

modest

Registered User.
Local time
Yesterday, 19:14
Joined
Jan 4, 2005
Messages
1,220
Because VB is a newer language to me, I didn't know if this was possible. Here's my scenario:

I have a "Main" form open that looks up a location by name, if the name matches more than one location I open a new form with the following code.
Code:
     Case Is > 1
            MsgBox "Found more than one match for your location."
            DoCmd.OpenForm "Multiple Matches", acNormal

"Multiple Matches" allows me to select the location from a list. The value is then put on my "Main" form. This value is needed for other functions to run. So even though "Multiple Matches" gains focus, "Main" still runs it's code in the background and I get errors before I can even select the correct location.

Is there a way to pause and restart my code based on whether Multiple Matches is open. I was considering doing a while loop, but I thought it might eat up too much memory.

Please let me know my best option (if there is one).

Thank you all I know this was a lot to read and understand,
Modest
 
Is it possible to pass a variable as a parameter into a form?

Or should I put
Code:
do while isnull(me.fieldname.value)
loop
after opening the other form?

Because I need some sort of pause.


surely there must be a reference to a system file or some thing else that put's a pause in the windows queue. ....someone? anyone?
 
Last edited:
...please...
 
What kind of errors are you getting? I find this situation awkward. Since VB is event-driven there has to be a good way to control the flow. Can you post the code from your main form so we can see what's going on?
 
Not sure I fully understand what you're trying to do but something like

Case Is > 1
MsgBox "Found more than one match for your location."
DoCmd.OpenForm "Multiple Matches", acNormal

End Select
ExitSub


orCase Is > 1
MsgBox "Found more than one match for your location."
DoCmd.OpenForm "Multiple Matches", acNormal

DoEvents ?
 
Sorry for not being clear and THANK YOU for responding. I'm not getting any error per say. I'll give more code on what's happening. I just try to not post too much so I don't frighten lazy people away :)

Code:
'find the correct origin for a givin location
    Set rs = FindCityState(strTable, _
                          [Forms]![Main]![oCity].[Value], _
                          [Forms]![Main]![oState].[Value], _
                          Me.Origin)            'set recordset pointer
    Select Case rs.RecordCount
        Case 0
            MsgBox "Could not locate " & Me.oCity.Value & ", " & Me.oState.Value & "." & vbNewLine & _
                   "Please try again."
            clearOrigin
            Exit Sub
        Case Is > 1
            MsgBox "Found more than one match for your location."
            DoCmd.OpenForm "Multiple Matches", acNormal
            '****************
            '* "Multiple Matches" updates my "Origin" field
            '****************
        Case Else
    End Select
  '===========================
                   
  
  'separate cities and state for pricing info
    tmpOrgCity = GetCity(Origin, ",")
    ...

Notice how "Origin" is used in GetCity().

This is how the process is running:
1. Open Multiple Matches
2. End Select
3. GetCity()
4. Debug

But I want it to work like this:
1. Open Multiple Matches
2. Get Origin from Multiple Matches
3. End Select,GetCity()..and so on

:::Multiple Matches has a drop down list that allows the user to pick what city he/she wants, so this cannot be automated:::


Thank you again,
Modest

--the only way i can think of to do it is by putting everything into their own functions and ordering it that way. i dont like timed events so sleep() is out of the question. I need something more like a getkey(), but for my field... so when i press the "ok" button on my Multiple Matches form.
 
Last edited:
Modest,

Using things like the Shell command, you have the ShellAndWait.

Within Access, you're going to have to use something like a Global
to hold a status:

Code:
blnNeedToWait = True
DoCmd.OpenForm "SomeForm"  <- SomeForm will set blnNeedToWait False
                              when it exits.

While blnNeedToWait
   Sleep(1)
   DoEvents
   Wend

Wayne
 
Found the solution. All that was needed was to change:
DoCmd.OpenForm "Multiple Matches", acNormal

to:
DoCmd.OpenForm "Multiple Matches", acNormal , , , acFormEdit, acDialog

because the dialog holds the focus and pauses the system until closed.



Hope this helps whomever else might need it.
Wayne, I'm not sure if your code worked because I never got the chance to use it , but thank you none the less.
And I appreciate everyone else who has made a comment/suggestion.

-modest
 
Last edited:

Users who are viewing this thread

Back
Top Bottom