Create a report from form

G

Guest

I have created a form. I now want to create a command button that opens a
report but only with the record (with detail records in subform) to populate
the report. Everytime I create the report, it brings in all records not the
one that is on the screen. That is the only record that I want to appear on
the report. I would then click on the commad button and the report would open
up with that record only.

Many thanks in advance.
 
J

Jeff Boyce

While it is possible to tell Access to take a form and print it, it may not
be a good idea. After all, forms are intended to be used as on-screen
displays, while reports are intended to fit/work on a printed page. And, as
you've found, telling Access to "print my form" gets ALL the records
associated with that form.

Two alternate approaches:

1. Create a report, with the layout you need for print. Add a command
button from the form to open THAT report, and send along the ID of the
record being viewed on the form. See Access HELP for the exact syntax of:
DoCmd.OpenReport ,,,,

2. Modify the way your form loads its records so it only loads one. Send
that to print.

I recommend the former.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
S

Steve

It appears the OP may know this but I just wanted to point it out ---
Since he has a form/subform, the OP needs a report/subreport.

I also agree with the recommendation to use approach #1.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
L

Larry Linson

Jeff Boyce said:
2. Modify the way your form loads its records so it only loads one. Send
that to print.

Just to clarify... I believe Jeff means that you must change the Form's
Recordsource so it retrieves only the one Record you want to Print; if you
just see one Record because the Form is in single-form view, but the
Recordsource includes additional Records, all will be printed if you Print
the Form.

Larry Linson
Microsoft Access MVP
 
S

Steve

1. Create a report, with the layout you need for print. Add a command
button from the form to open THAT report, and send along the ID of the
record being viewed on the form. See Access HELP for the exact syntax of:
DoCmd.OpenReport ,,,,>>

Yes, that's correct but Jeff recpmmended approach #1

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 

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