Allen, I'm confused.
1- If I put two parameters in the query for fields [BelgeNo] (Text field
like B-0001, etc) and [MTIsim] (Text field again), I have no problem.
When I write the following (The button is Command72, and F1 and F2 are two
unbound controls in the report, I am asked what F1 is, what F2 is and also
what B is (The same query without the parameters, and there is no B
anywhere??????)
The data to be passed to the report is in the controls BelgeNo and
Combo14.
When I use """'s instead of ", the code gives an error even before closing
the event procedure window.
What am I doing wrong?
Thanks for your help...
Private Sub Command72_Click()
On Error GoTo Err_Command72_Click
Dim strWhere As String
Dim stDocName As String
strWhere = "(F1 =" & Me.BelgeNo & ") AND F2=" &Me.Combo14&)"
stDocName = "Teslimat Belgesi"
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_Command72_Click:
Exit Sub
Err_Command72_Click:
MsgBox Err.Description
Resume Exit_Command72_Click
End Sub
Allen said:
You could put a couple of unbound controls on the report, and a command
button to open the report:
This kind of thing:
Dim strWhere As String
strWhere = "(InvoiceID = " & Nz(Me.InvoiceID,0) & ") AND (City = """
& Me.City & """)"
DoCmd.OpenReport "Report1", acViewPreview, , strWhere
If you prefer, you can use parameters in the query, and Access will ask
for values when the report runs.
There's an example of how to do this with dates in this article:
http://allenbrowne.com/casu-08.html