Print the current record shown on form using a report

G

Guest

Users can select certain students from the database and edit them in a form.
(no problem here).
To print a student report (from the form) the users click on a command
button but a query asks for the Student ID (no problem here neither).
However, users are complaining: Why they have to type the Student ID when
they want to print the current student shown on the form?
So, is there a way to do this? The current report associated with the
command button is based on a query that asks for the Student ID. I know I
have to create a new report without any criteria but how Access is going to
know to print the current record?
Thank you for your help :)
 
F

fredg

Users can select certain students from the database and edit them in a form.
(no problem here).
To print a student report (from the form) the users click on a command
button but a query asks for the Student ID (no problem here neither).
However, users are complaining: Why they have to type the Student ID when
they want to print the current student shown on the form?
So, is there a way to do this? The current report associated with the
command button is based on a query that asks for the Student ID. I know I
have to create a new report without any criteria but how Access is going to
know to print the current record?
Thank you for your help :)


Code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[StudentID] = " &
Me![StudentID]

The above assumes a [StudentID] field that is a Number Datatype.

If [StudentID] is Text Datatype, then use:

"[StudentID] = '" & Me![StudentID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 

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