SteveL13
asked on
Trying to make a message box appear if two criteria in a table exists
I am trying to make a message box appear if any one record in a table has TWO fields that match what the user is entering entered exists.
But I'm getting a syntax error with:
If DCount("[LOT]", "HEADER", "[LOT] = " & Forms!frmCRMAIN.Form!subfr mHEADER.Fo rm!txtLOT & "'" & " AND [SERIAL] = '" & Forms!frmCRMAIN.Form!subfr mWRHEADER. Form!txtSE RIAL & "'") Then
Note: Serial is a number field. Lot is a text field.
But I'm getting a syntax error with:
If DCount("[LOT]", "HEADER", "[LOT] = " & Forms!frmCRMAIN.Form!subfr
Note: Serial is a number field. Lot is a text field.
ASKER
Serial is a number field. Lot is a text field.
then try:
If DCount("[LOT]", "HEADER", "[LOT] = '" & Forms!frmCRMAIN.Form!subfr mHEADER.Fo rm!txtLOT & "' AND [SERIAL] = " & Forms!frmCRMAIN.Form!subfr mWRHEADER. Form!txtSE RIAL) Then
If DCount("[LOT]", "HEADER", "[LOT] = '" & Forms!frmCRMAIN.Form!subfr
Steve,
This is why I generally do:
This is why I generally do:
strCriteria = "[LOT] = '" & Forms!frmCRMAIN.Form!subfrmHEADER.Form!txtLOT & "' AND " _
& "[SERIAL] = " & Forms!frmCRMAIN.Form!subfrmWRHEADER.Form!txtSERIAL
If DCount("[LOT]", "HEADER", strCriteria) Then
It allows me to put a breakpoint on the IF line and inspect the value of strCriteria during debugging, to make sure I have the correct wrapping of text and numeric values that are being embedded in strCriteria.
ASKER
Am getting Expected list separator or )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this
If DCount("*", "HEADER", "[LOT] = '" & Forms!frmCRMAIN!subfrmHEAD ER.Form!tx tLOT & "' AND [SERIAL] = " & Forms!frmCRMAIN!subfrmWRHE ADER.Form! txtSERIAL) Then
If DCount("*", "HEADER", "[LOT] = '" & Forms!frmCRMAIN!subfrmHEAD
ASKER
Works perfectly. Thanks.
If DCount("[LOT]", "HEADER", "[LOT] = " & Forms!frmCRMAIN.Form!subfr
if [LOT] is text, then try:
If DCount("[LOT]", "HEADER", "[LOT] = '" & Forms!frmCRMAIN.Form!subfr