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

SYNTAX problem - open report based on form selections

Status
Not open for further replies.

sjdk

Programmer
May 2, 2003
59
US
I know this is something simple....but I am not seeing the obvious...

Here is the code on frmLabelOptions...What i am trying to do is click on a check box(es) on frmLabelOptions, then open a report based on the check box(es) selected.

Private Sub Command30_Click()

Dim strWhere As String
Dim stDocName As String

strWhere = "where 1=1"
stDocName = rptSKLabelsBuysSvcs


If Me.Elem = True Then
strWhere = strWhere & " or (qrySKLabelsBuysSvcs.tblDistricts.ElementarySchool = true)"
End If

If Me.Inter = True Then
strWhere = strWhere & " or (qrySKLabelsBuysSvcs.tblDistricts.IntermediateSchool = true)"
End If

If Me.Mid = True Then
strWhere = strWhere & " or (qrySKLabelsBuysSvcs.tblDistricts.MiddleSchool = true)"
End If

If Me.High = True Then
strWhere = strWhere & " or (qrySKLabelsBuysSvcs.tblDistricts.HighSchool = true)"
End If



DoCmd.OpenReport "rptSKLabelsBuysSvcs", acPreview, , strWhere



End Sub


This is the error I am getting...

Run-time error '3075':
Syntax error (missing operator) in query expression '(where 1=1 or (qrySKLabelsBuysSvcs.tblDistricts.ElementarySchool=true))'.


What am I missing?
Thanks in advance!
 
Replace this:
qrySKLabelsBuysSvcs.tblDistricts.ElementarySchool
with this:
ElementarySchool

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the quick response! Unfortunately, it produced the same error message. :-(
 
the same error message
Really ? This one ?
Syntax error (missing operator) in query expression '(where 1=1 or (qrySKLabelsBuysSvcs.tblDistricts.ElementarySchool=true))'.

Check the name of the fields produced by the reportt's underlaying query.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Terribly sorry...error was:
Syntax error (missing operator) in query expression '(where 1=1 or (ElementarySchool=true))'.

I double checked the query and made sure that the field is indeed spelled 'ElementarySchool', and it is. I also double checked the data type of 'ElementarySchool' and it is 'yes/no'.

Any other things i should be looking at?

Many thanks for your time thus far!
 
Remove the WHERE keyword from strWhere.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
ACK!!! I knew it was something simple! That did the trick! MANY MANY Thanks for your time!
 
Furthermore, as you use the OR operator, I'd replace 1=1 with 1=0.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top