Print an individual record via a Report

J

jamiecockrill

Hi there, I'm quite new to Access, so please be gentle!

I've created a Report to set the format in which I want my records
printed, however at the moment, when I click the Print Record button
that I created with a Wizard, if prints every single record in the
table I referred it to.

What I have is a 'View Work Requests' form called "View Request2" which
prompts me for a Work request number (field in the table is called
'Project Reg Number'). It then searches the database and returns the
data to the form. I essentially want a button that prints that record.

I've tried sticking an SQL WHERE query in, but it evidently doesn't do
very much!

Thanks for you help

Jamie

PS, the code for that section is:

Private Sub print_report_Click()
On Error GoTo Err_print_report_Click

DoCmd.OpenReport "Print Report", acNormal, "[Project Reg
Number]=View Request2![Project Reg Number]"

Exit_print_report_Click:
Exit Sub

Err_print_report_Click:
MsgBox Err.Description
Resume Exit_print_report_Click

End Sub
 
J

jamiecockrill

After a bit of fiddling with the VB Code, I now have this as my query:

DoCmd.OpenReport "Print Report", acNormal, , "[Project Reg Number]
= " & Me![Project Reg Number]

this seems to bring up a dialog box, with the Project Reg Number as the
variable name (or something) and then a text-box to enter the Project
Reg Number (which is essentially copying what's above it)

So it looks like:

Enter Parameter value (the dialog box heading)
W0982 (an example of the record
numbers I use)
[Box to put number in] (i.e. just putting W0982, in this case,
back in)

thanks

Jamie
 
J

jamiecockrill

I received a fix on another forum, so I thought I'd post it here. I
replaced the following:

"[Project Reg Number] = " & Me![Project Reg Number]

with:

"[Project Reg Number]= Forms![View Request2]![Project Reg Number]"

and it worked fine (where View Request2 is the form name and Project
Reg Number is the text-box containing the data I wanted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top