Subform strSQL Null Values

  • Thread starter Thread starter Bryan Hughes
  • Start date Start date
B

Bryan Hughes

Hello,

I have subforms that load depending on the selection on a cbo.
The recordsource is set by an SQL string from the main form in the cbo
change event.

All of my subforms load correctly except for one.
Everytime I try to load it I receive the following Error:
Error No: 3075; Description Syntax error (Missing Operator) in query
expression '[CRAEM] tblClient_Referral WHERE [CFID] = '"[strCriteria]".

I am assuming this being caused by a null value in the [CRAEM] field.

Here is the code used to load subform:
Me.subClient_Information.SourceObject = "fsubClient_Referral"
strSQL = "SELECT DISTINCTROW CFID, CRD, CRBN, CRB, " _
& "CRA, CRASA, CRAC, CRAS, CRAZ, CRAPE, CRAEM " _
& "tblClient_Referral WHERE CFID='" & strCFID & "';"
Me.subClient_Information.Form.RecordSource = strSQL
Me.subClient_Information.Visible = True
Me.subClient_Information.SetFocus

Would a null value in the field cause this error?
How should I fix it?

If not what is the problem and how should I fix it?

Thank you for the help.
-Bryan
 
Your code is the problem. You are forgetting FROM between CRAEM and
tblClient_Referral.

Kelvin
 
1. (Unless you use a strange naming convention,) strCriteria cannot be Null
if you declare it as a String.

2. You left out the word "FROM" before the Table name. Could this be the
problem?
 
Thank you,

Don't I feel stupid. I stared at this a thousand times and couldn't see
FROM was missing.

Thanks again

-Bryan
 
Back
Top