Wayne,
I'll use the name cmdRunReport as you form's button name...
(you use your own)
With your form in Design mode...
Select the cmdRunReport button.
In the Properties dialog box, locate the button's OnClick event.
Put your cursor in the text box next to the OnClick.
Using the little arrow on the right of the text box, and select
[EventProcedure]
Now click the little box on the right, with 3 dots (...)
You are now in the form's VB Module, and you should see...
Private Sub cmdRunReport_Click()
| <= Cursor is here..
End Sub
Now, add my code between the lines...
Private Sub cmdRunReport_Click()
DoCmd.OpenReport "ReportName", acViewPreview, , "DrawingNo = " &
Me.DrawingNo"
End Sub
Close out the module, save the form, and then run the form.
When you click the cmdRunReport, the report will run, filtered by the
DrawingNo currently on the form.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."
"ReportName", acViewPreview, , "DrawingNo = " & Me.DrawingNo"
Wayne26el said:
I guess I'm so new at this that I don't understand or maybe I didn't make
myself clear I'm not sure where to put the statement "DoCmd.OpenReport
"ReportName", acViewPreview, , "DrawingNo = " & Me.DrawingNo" (without
the
quotes). I created a button to preview the report on the form in which I
found the drawing no which automatically gives me an embedded macro. I'm
not
sure how to or where to put the statement above, which gives me a syntax
error. I think I starting in the wrong direction.
Wayne
Al Campagna said:
Wayne,
Well, the form must remain open while the report is run. Other
than that, anything I would offer would be a guess.
I have never used Macros, but in VB, another way to filter the report
is to use the Where argument in the OpenReport method.
(from a button on the form - all code on one line)...
DoCmd.OpenReport "ReportName", acViewPreview, , "DrawingNo = " &
Me.DrawingNo
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your
life."
Al,
I have a similar report but I am using a DrawingNo as my key field
to
get my report. But when I put in =[Forms]![frmQuote]![DrawingNo] in the
filter name in my embedded macro. I get an error which says "The
Microsoft
Office Access database engine could not find the object" and the list
the
drawing no. that I'm looking for the report on.
Wayne