Pausing until user closes a form

JBurlison

Registered User.
Local time
Today, 13:26
Joined
Mar 14, 2008
Messages
172
i want the user to have to change the location of an item if its location is at the wherehouse how do i pause it till the user presses "ok" on the popup form?


Code:
Private Sub Command6_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Main Inventory", dbOpenDynaset)


If Me.SAI_Serial_Number.Value = "" Or IsNull(Me.SAI_Serial_Number.Value) Then
    MsgBox "You Must enter a Serial Number in order to Ship!"

      Else

With rs
   .FindFirst "[Sai Serial Number] = '" & Me.SAI_Serial_Number.Value & "'"
   If .Fields("Location") = "SAI, Shelton" Then
        DoCmd.OpenForm "Change Location"
        'Need to Pause untill the user has changed the location
   .Update
End With

DoCmd.GoToRecord
Me.SAI_Serial_Number.SetFocus

End If
   
End Sub
 
Code:
DoCmd.OpenForm "Change Location",acNormal,,,,acDialog
 
or - if you dont want dialog forms {because you may want to resize the form, or you may want to open other things, while you are waiting for the popup form to close etc ....}

declare a global function as follows

Code:
Function IsOpen(strName As String, Optional objtype As Integer = acForm)
    IsOpen = (SysCmd(acSysCmdGetObjectState, objtype, strName) <> 0)
End Function


and then in your code

Code:
while isopen("myform",acform ) {acform not necessary, but for other objects - eg acquery, acreport etc, it is necessary)
    doevents
wend
 
While the above (Isopen) approach is a very worthy and clever solution, Access will be merrily consume a large percentage of you CPU resources - 50-60% when I was testing it on a 2.4Ghz dual Core machine. Which is unfortunate as it is a neat solution. I would certainly use it in the right circumstance, and as long as you don't expect the form to be open too long and you don't expect the PC to be doing much else, then it should be fine for this case.

Gemma, this is not a criticism of your answer, just a word of caution.

Chris
 

Users who are viewing this thread

Back
Top Bottom