I use the following code to open form2 using the AfterUpdate_Event from a text box on a form1. All works well until I return to form1 and clear that same Text box called [ItemsR4SB].
This triggers a MsgBox Syntax Error (missing operator) in query Expression '[ItemId] = '
How can I modify the below code so that when or if I clear the [ItemsR4SB] text box on form1 the warning does not occur?
Code
Private Sub ItemsR4SB_AfterUpdate()
On Error GoTo Err_ItemsR4SB_AfterUpdate
If Nz(DLookup("ItemID", "tblItems", "[ItemID]=" & Me![ItemsR4SB]), "") <> "" Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmItemsR4"
stLinkCriteria = "[ItemID]=" & Me![ItemsR4SB]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Item Number Entered is not Registered in QMS!"
End If
Exit_ItemsR4SB_AfterUpdate:
Exit Sub
Err_ItemsR4SB_AfterUpdate:
MsgBox Err.Description
Resume Exit_ItemsR4SB_AfterUpdate
End Sub
Thanks, UncleG
This triggers a MsgBox Syntax Error (missing operator) in query Expression '[ItemId] = '
How can I modify the below code so that when or if I clear the [ItemsR4SB] text box on form1 the warning does not occur?
Code
Private Sub ItemsR4SB_AfterUpdate()
On Error GoTo Err_ItemsR4SB_AfterUpdate
If Nz(DLookup("ItemID", "tblItems", "[ItemID]=" & Me![ItemsR4SB]), "") <> "" Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmItemsR4"
stLinkCriteria = "[ItemID]=" & Me![ItemsR4SB]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Item Number Entered is not Registered in QMS!"
End If
Exit_ItemsR4SB_AfterUpdate:
Exit Sub
Err_ItemsR4SB_AfterUpdate:
MsgBox Err.Description
Resume Exit_ItemsR4SB_AfterUpdate
End Sub
Thanks, UncleG