Form criteria to print report

P

PHisaw

I have an unbound form with several combo boxes for report criteria. In the
OnClick event of CboReportName (lists report names to choose from) I have the
following code:
Private Sub CboReportName_Click()
Dim stWhere As String
Dim stDoc As String
stDoc = Me.CboReportName

If Not IsNull(Me.CboSlsp) Then
stWhere = stWhere & "And [Salesman]= " & Me.CboSlsp & """"
End If
DoCmd.OpenReport stDoc, acViewPreview, , stWhere
End Sub

I have only listed one because I can't get past the first combo box. It
gives the error message "3075 Syntax error (missing operator) in query
expression '(And[Salesman]=John Doe")'.

Any help with this would be greatly appreciated.
Thanks in advance,
Phisaw
 
P

PHisaw

Okay, I finally got the slsp part to work - the code I copied didn't work
quite the same. I entered code for the next combo box and with the two boxes
containing info that I know should produce a report, I'm getting a blank
report. Code is as follows:
Private Sub CboReportName_Click()
Dim stWhere As String
Dim stDoc As String
stDoc = Me.CboReportName

If Not IsNull(Me.CboSlsp) Then
stWhere = "(Salesman = """ & Me.CboSlsp & """)"
End If
If Not IsNull(Me.CboStage) Then
stWhere = "(Stage = """ & Me.CboStage & """)"
End If
DoCmd.OpenReport stDoc, acViewPreview, , stWhere


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top