passing values from forms to subforms...

G

Guest

I have designed a pretty nifty form which has a subform embedded within it.
In taking the advice suggested on this forum and others, I have handwritten
the vba that drives the parent form and need to pass the value of the
Openargs parameter used to load the parent form to do the same for the
subform.

How do I do this?

I am beginning to write the necessary queries that will drive the subform
and will need to pass values from the parent form to establish the criteria
for the queries.
 
G

Guest

Sorry, but that is not going to work. First, the OpenArgs is passed using
the OpenForm method. You do not open a subform, so that will not work.
Interestingly, the subform actually opens before the parent form, so the
value of the parent form's OpenArgs will most likely not be available when
the sub form opens.
If you want to pass the value received from the calling form as the OpenArgs
in the parrent form to the subform, you could do that in the Load event of
the parent form.
If you can provide some detail on your objective, perhaps we can help.
 
G

Guest

Well, the parent form is really just a collection of labels displaying values
from the "parent" set of data. I've written a series of queries that sets
the captions of the labels on the parent form to show the user what parent
data they are dealing with.

The subform displays a "child" dataset, whose records I would like to have
the capability of browsing and commenting on. In order for the subform to
pull applicable child-data, I need to pass some sort of value from the parent
form. Maybe the comment box on the previous form that is currently
responsible for passing the selected combo box value through Openargs to be
used by the parent form can be used to first pass the value to the subform...
does this make sense?
 
G

Guest

This is a most unusual thing to do. I would not recommend it, but you may
try filtering the subform's data based on what you recieved in the OpenArgs
(which I assume you use to select a record). Once all your labels are
loaded, set the row source of the subform:
Me.MySubForm.Form.RowSource = "SELECT * FROM FooBar WHERE [SomeField] = " &
Me.OpenArgs
 

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