Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle After Update when Text box is Null 1

Status
Not open for further replies.

uncleG

Technical User
Jun 10, 2004
63
US
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
 
You may put this line before the DLookUp call:
If Trim(Me![ItemsR4SB] & "") = "" Then Exit Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PH, so thats how you Say "if nothing do nothing in Access. It Worked Great. Thank You UncleG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top