I need to pull a result from a query and store it as a variable to be compared to criteria for an IF / THEN statement. What is the correct syntax for pulling a result, from say column 4 in a query, and saying if the record exists, do this. If it doesn't exist, do this -- in VBA? My query will only ever return 1 result or it will return 0 results.
If 1 result is returned, it needs to go to Time_OUT form. If 0 results are returned, it goes to Time_IN form. Thanks a ton in advance!
As a start, this is the code I have (The part where it says "If Me.MO_ID=Null" Then is where I don't know the correct syntax to use):
Option Compare Database
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
DoCmd.OpenQuery "Open MO Evaluation Query", acViewNormal, acEdit
If Me.MO_ID = Null Then
DoCmd.OpenForm "Time_IN_Form", acNormal, "", "", , acNormal
Else
MsgBox "You must log out out of your current MO first."
DoCmd.OpenForm "Time_OUT_Form", acNormal, "", "", , acNormal
DoCmd.GoToControl "Time_OUT"
End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Bookmarks