Printing reports for current record

arturo_w

New member
Local time
Today, 02:38
Joined
Jun 3, 2004
Messages
9
I have created a report from a query to print a cover sheet for each record on an Access DB.

I have created a "Print Cover" button on the record's input form but the only way I can get the report to print for the specific record is to set a parameter on the report query that asks for the record ID [Enter Record ID:] and only after I enter the specific record ID does the report print correctly. Otherwise it always prints the cover sheet with the information of the first record. :confused:

Is there a parameter that I can use on the query so that when I open a record I can just click on "Print Cover" and get a print out of the current record without having to enter the {Record ID}.

Thanks,
Arturo
 
In a nutshell, add the wherecondition argument to your OpenReport command.

It should look something like this:
Code:
DoCmd.OpenReport "[[COLOR=RoyalBlue]YourReportName[/COLOR]]", acPreview, acFilterNormal, _
"[[COLOR=RoyalBlue]YourRecordIDFieldNameIn[B]Report[/B]RecordSource[/COLOR]] = " & _
Me.[[COLOR=RoyalBlue]YourRecordIDFieldNameIn[B]Form[/B]RecordSource[/COLOR]]
 
Last edited:
I tried the changing the code but I'm still getting the first record only. This is what I have, let me know if there's anything wrong:

Private Sub PrintCover_Click()
On Error GoTo Err_PrintCover_Click

Dim stDocName As String

stDocName = "Financial"
DoCmd.OpenReport stDocName, acFilterNormal, "[Image_ID] = " & Me.Image_ID

Exit_PrintCover_Click:
Exit Sub

Err_PrintCover_Click:
MsgBox Err.Description
Resume Exit_PrintCover_Click

End Sub
 
Nevermind, I figured it out ..... Thanks, it works great!
 
How did you get that to work?

I want to be able to the current record. I used your code example and got the following error:
Syntax error (missing operator) in query expression '([tblNestTree.NestTreeID]=EELR 22)'

Here is a snippet of the code I used:

stDocName = "rptOspreyInfo"
DoCmd.OpenReport stDocName, acPreview,_ acFilterNormal, "[tblNestTree.NestTreeID]=" & Me.NestTreeID

I'm curious what you did to fix your problem.

Thanks!
 
Im kinda newbie here..can anyone tell me how to insert this condition?

joeselch said:
In a nutshell, add the wherecondition argument to your OpenReport command.

It should look something like this:
Code:
DoCmd.OpenReport "[[COLOR=RoyalBlue]YourReportName[/COLOR]]", acPreview, acFilterNormal, _
"[[COLOR=RoyalBlue]YourRecordIDFieldNameIn[B]Report[/B]RecordSource[/COLOR]] = " & _
Me.[[COLOR=RoyalBlue]YourRecordIDFieldNameIn[B]Form[/B]RecordSource[/COLOR]]
 
Typically, this code would go in the On Click event of a button.
 

Users who are viewing this thread

Back
Top Bottom