Printing selected record

  • Thread starter Thread starter Andy Welch
  • Start date Start date
A

Andy Welch

I want to create a button on a form that will print a few
items of the selected record only.

I know how to create a report that will print the items I
want but it will only print all records - not the selected
record only.

Thanks,

Andy Welch
 
Andy Welch said:
I want to create a button on a form that will print a few
items of the selected record only.

I know how to create a report that will print the items I
want but it will only print all records - not the selected
record only.

The DoCmd.OpenReport command has an optional WHERE argument that can be used to
apply a filter to the report as it is opened. If you set this to refer to the
same Primary Key field as is currently displayed on the form, then the report
will only include that one record.

Making another decision that I will never understand MS included a wizard option
for a new command button to "open another form with data that matches the
current form", but did not provide a corresponding option for "open a report
with data that matches the current form", even though most people need that at
least as often.

If you'd like to take advantage of the wizard though you actually can. Just go
through the wizard and tell it to open a form and choose the same current form.
Take the option to "Open the form and find specific data to display". When you
complete the wizard you should be able to modify the code by changing
DoCmd.OpenForm to DoCmd.OpenReport and then change the name of the object being
opened to your report.
 
Back
Top