Preview report button on a subform

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
Back
Top