printing report of current record as seen in form

frangipani

Registered User.
Local time
Today, 23:58
Joined
Nov 10, 2002
Messages
22
Hi

Can anyone help me please - I have a form for data input. From this form I would like to print a report I have designed. but only for the record the user has just input - i.e. the current record.

any help appreciated.

Thanks
 
You just need to add selection criteria to your OpenReport command. It will go something like this-

DoCmd.OpenReport "Report Name" ,,,"tblRptID = " & Me!recID

Where tblRptID is the key on your report and recID is the key to the current record. Check Help to get correct syntax.
 
You'll need to save the record first though
 
Thanks for the tips guys

Have tried to do as you said Peter - but every time I go to preview the report it comes up with a blank report

I have:

DoCmd.OpenReport stDocName, acPreview, , "ra_no = 'me!ra_no'"

Where Ra_No - is the field name on the report I want to print and the current record on the form.

If I substitute me!ra_no for an actual value from that field it does show me the report for that record.

Help please!!!!!
 
Have you saved the record before previewing the report - as Rich suggested.
 
Hi Peter -

Yes I think the record is saved - It does the same for any record in the database

But - if I substitute an actual value for ra_no i.e ra_no = "cm2"

'DoCmd.OpenReport stDocName, acPreview, , "ra_no = 'CM2'"

It will print just the record for CM2

When I use
'DoCmd.OpenReport stDocName, acPreview, , "ra_no = 'me!ra_no'"

It shows me a blank report?

Help please????

Thanks
 
Attach a query to the report

The way that I have done this is to base the report on a query. The command button simply opens the report in acpreview.

The query contains all the fields that I want in the report. The key is to use the primary key field to determine the scope of the report. My query uses a field called address_id (substitute "ra_no") and uses a criteria of:

[Forms]![YourFormName]![ra_no]

It works very well for me. Good luck.:)
 
It is looking for an id of "me!ra_no" - take the field out of the quotations, as below_

DoCmd.OpenReport stDocName, acPreview, , "ra_no = " & me!ra_no
 
Hi Peter

thanks again for your reply

It is working for:
DoCmd.OpenReport stDocName, acPreview, , "ra_no = [Forms]![Fm_Main]![ra_no]

Can not get it working the other way.

I am now trying to add an additional condition, i.e and "category = [Forms]![Fm_Main]![cat]"

But this fails to work, where am I going wrong here?

And it also comes up with a message saying This Recordset is not updateable? Do you know why this appears?

Thanks again

Frangi
 

Users who are viewing this thread

Back
Top Bottom