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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Syntax error

Status
Not open for further replies.

camidon

Programmer
May 9, 2000
268
US
Can someone tell me why I get a syntax error when I step through this code?:

If Not IsNull(cmbBeginningZone) Then
If Not IsNull(cmbEndingZone) Then
strCriteria = strCriteria & "[tbl_Customer].ZoneID] >= "
strCriteria = strCriteria & cmbBeginningZone & &quot; AND <= &quot;
strCriteria = strCriteria & cmbEndingZone
Else
strCriteria = strCriteria & &quot;[tbl_Customer].[ZoneID] = &quot;
strCriteria = strCriteria & cmbBeginningZone
End If
End If

The query that gets plugged into my openreport method looks like this:

&quot;[tbl_Customer].ZoneID] >= 1 AND <= 6&quot;

Why shouldn't that work?

Thanks in advance!

Chris
 
I fixed it. I was missing a [ in my Fieldname.

Stupid mistake on my part.

Also, I had to use BETWEEN instead of the <= >=

That seemed to have corrected my problems and now my reports are kicking off beautifully.

Thanks guys.
 
Your missing an opening bracket before ZoneID in line:
strCriteria = strCriteria & &quot;[tbl_Customer].ZoneID]

You don't need to use those brackets. They're only required if the name contains spaces [my table].
 
The variable name needs to be repeated and the <= >= will work for you.

&quot;tbl_Customer.ZoneID >= 1 AND tbl_Customer.ZoneID <= 6&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top