Preview report button on a subform

G

Guest

I have a subform with a button which allows me to run a report using a
parameter from the form (a course booking reference id) I pass the data to a
query using the following script.

STUDY_LEAVE_RECS.ID=Forms![STUDY_LEAVE_RECS]![ID];

This format works ok when running the sub form as a stand alone form ( and
from other forms), but when the form is nested in the main form and run - the
script fails. How can I correct this?

I have tried altering the query to refer to the subform, but I don't seem to
be able to get the correct syntax. Can anyone please suggest the correct way.

Many thanks.

Peter
 
J

Jeff Boyce

Peter

Once you've embedded a form as a subform, it's "address" changes. Take a
look in Access HELP for "expressions" -- you'll need to use something like
(untested aircode - your syntax may vary):

Forms!frmYourParentForm!sfrmYourSubformControlName.Form![ID]

Note that this points to the name of the control, not the name of the
(sub)form.
 
G

Guest

Thanks Jeff, I'm really glad that there are people like you out there.

For reference, the final version I used for the query is

WHERE
(((STUDY_LEAVE_RECS.ID)=[Forms]![course_booking]![study_leave_recs].[Form]![id]));

Thanks again.

Peter


Jeff Boyce said:
Peter

Once you've embedded a form as a subform, it's "address" changes. Take a
look in Access HELP for "expressions" -- you'll need to use something like
(untested aircode - your syntax may vary):

Forms!frmYourParentForm!sfrmYourSubformControlName.Form![ID]

Note that this points to the name of the control, not the name of the
(sub)form.

--
Good luck

Jeff Boyce
<Access MVP>

PETER said:
I have a subform with a button which allows me to run a report using a
parameter from the form (a course booking reference id) I pass the data to a
query using the following script.

STUDY_LEAVE_RECS.ID=Forms![STUDY_LEAVE_RECS]![ID];

This format works ok when running the sub form as a stand alone form ( and
from other forms), but when the form is nested in the main form and run - the
script fails. How can I correct this?

I have tried altering the query to refer to the subform, but I don't seem to
be able to get the correct syntax. Can anyone please suggest the correct way.

Many thanks.

Peter
 

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