Parameter issues w/ Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey there folks,
I'm having trouble with a report. It's based on a select query, and contains
a subreport based on a table. The report is set to preview by a command
button in another form. When you click the button, the report will come up
only after you enter parameter values for both the report and the subreport,
i.e, the work order number for both the hours log and the regular work order.
Even stranger is that if you don't scroll through at least one other record
and come back to the one you are working on, before clicking the preview
button, the report will not display your information! (Even if you save the
info before pressing the button) All I want the report to do is pop up in
preview, displaying the record that matches the Work Order Number I was
working on (or current record). Help please!
 
You might want to check out this link:
(Q) I'm trying to print out only the current record from my form in a report
but each time all the records print out. How can I print only one record
using a report?

(A) Use the OpenReport's Where condition to specify your record. For
example, the following code placed behind a command button on the form would
use the RunID control on the form to restrict the Report to only one record.

http://www.mvps.org/access/reports/rpt0002.htm
 
Duane, I'm not sure where to put this code. I tried to put it in a macro with
an OpenReport function under the Where condition, but it would not let me.
(The macro is assigned to the command button) Obviously, "SomeReport" is
where I enter the name of the report I'm trying to bring up, but what about
DocName? Should that be the name of the form where the command button is
located? I also tried to use the SQL expression that the Help gave me
([fieldname]=Forms![formname]![controlnameonform]), but it also spat out
parameter value pop up boxes. Sorry for the silly questions, I'm still pretty
new to Access.
 
PS- I found where the code goes, but now it's giving me a "Compile error:
invalid outside procedure" error, with "rptWOPrintout" highlighted. Here it
is:

Dim strWOPrintout As String
Dim strWhere As String
strWOPrintout = "rptWOPrintout"
strWhere = "[RunID]=" & Me!RunID
DoCmd.OpenReport strWOPrintout, acPreview, , strWhere
 
Yes, I did- when I tried to put "OpenReport" by itself in a macro and run it,
this error came up, as well as when I pasted it into a module window. Any
thoughts on what's causing this error? The Help box was loaded with jargon I
don't understand, I basically know nothing about VBA.
Thanks!
Dim strWOPrintout As String
Dim strWhere As String
strWOPrintout = "rptWOPrintout"
strWhere = "[RunID]=" & Me!RunID
DoCmd.OpenReport strWOPrintout, acPreview, , strWhere
 
I don't know what you have displaying in your properties, macros, or code
window. The solution is code only.

--
Duane Hookom
MS Access MVP


Mrs. Ellis said:
Yes, I did- when I tried to put "OpenReport" by itself in a macro and run
it,
this error came up, as well as when I pasted it into a module window. Any
thoughts on what's causing this error? The Help box was loaded with jargon
I
don't understand, I basically know nothing about VBA.
Thanks!
Dim strWOPrintout As String
Dim strWhere As String
strWOPrintout = "rptWOPrintout"
strWhere = "[RunID]=" & Me!RunID
DoCmd.OpenReport strWOPrintout, acPreview, , strWhere
 
Back
Top