Parent reference

M

MarianneZ

I've addressed this question in the reports group, but I have a more general
question.

The ID field in my database uniquely identies a customer. For different
applications in my database I want to the user to supply the info to
determine the ID, either an ID or a last name or a last name and first name.
So I've created a generic form that will determine the ID. I will then use
that ID to populate a report or a form.

My idea was to pass the ID value by storing it in the parent form or report
in a consistently-named unbound field as follows:

Parent!ttxtID.Text = Me!txtCustID.Text

This code would appear in a procedure for the subform.

I've tried this, popping up the subform from a Report_Open and a Report_Load
procedure. It doesn't work. In the debugger inside the subform's code I look
at the local expressions and Me's parent is never properly defined. Plus I
get Run-time error 2185, which says I can't reference a property or a method
for a control unless the control has focus.

This seems to me a common use for a subform. There must be a way of passing
data.
 
M

Marshall Barton

MarianneZ said:
I've addressed this question in the reports group, but I have a more general
question.

The ID field in my database uniquely identies a customer. For different
applications in my database I want to the user to supply the info to
determine the ID, either an ID or a last name or a last name and first name.
So I've created a generic form that will determine the ID. I will then use
that ID to populate a report or a form.

My idea was to pass the ID value by storing it in the parent form or report
in a consistently-named unbound field as follows:

Parent!ttxtID.Text = Me!txtCustID.Text

This code would appear in a procedure for the subform.

I've tried this, popping up the subform from a Report_Open and a Report_Load
procedure. It doesn't work. In the debugger inside the subform's code I look
at the local expressions and Me's parent is never properly defined. Plus I
get Run-time error 2185, which says I can't reference a property or a method
for a control unless the control has focus.

This seems to me a common use for a subform. There must be a way of passing
data.


Not sure I understand what you mean by your description of
the forms invilved. The following applies to a subform in a
main form or a subreport in a main report.

THe concept is fine, but you can not use the .Text property
for this. Use the .Value property instead:

Parent!ttxtID = Me!txtCustID

Note that subforms are initiated before the main form so the
main form may not be ready in the subform's Load event. The
Open event is way too early in either a form or report.
Note that I don't use A2007 enough to understand it, but I
don't see how a report's Load event can be of use.
 

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