Results 1 to 2 of 2
2004-06-24, 09:27 #1
- Join Date
- Apr 2002
- Amersfoort, Utrecht, Netherlands
- Thanked 0 Times in 0 Posts
query criteria from formfield (97nl)
I have a report that is based on a query
This report is printing information that is currently visable on a form
Now I want to have a button on the form that will open the report in preview mode, but I need to set the criteria of the formquery to the callnummer field of the form, so that it will only show the information of the current call on the screen.
How do I set a query criteria from a fromfield value?
Thank in advance for your reaction.
2004-06-24, 10:08 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: query criteria from formfield (97nl)
The DoCmd.OpenReport method has a WhereCondition argument.
DoCmd.OpenReport "rptMyReport", acViewPreview, , "CallNumber = " & Me.CallNumber
Here, rptMyReport is the name of the report, and CallNumber is the name of the field in the record source of the form and report. I have assumed that it is a number field. If it is text, you must enclose the value in quotes Chr(34):
DoCmd.OpenReport "rptMyReport", acViewPreview, , "CallNumber = " & Chr(34) & Me.CallNumber & Chr(34)