accessing subform controls try#2

  • Thread starter Thread starter drabbacs
  • Start date Start date
D

drabbacs

I asked this question in an earlier post but the reply was
less than helpful.

If I want to write a query based on a double click event
on a tabular-textbox contained in a subform contained in a
parent form, how would the WHERE clause be phrased?


To compare, in an earlier version of my database, I had a
form that contained a listbox, which displayed several
lines of data. The user could select a particular line and
doubleclick and this would execute a macro/query which
opened another form and diplayed details concerning the
selected line. That was accomplished using the bound
column property in the listbox and the on_dbl_click event.
The macro/query had a where clause something like...

Where userfield = forms![form_name].[listbox_name]

I want to do the same thing with this textbox in the
subform in the form. How do I write the where clause?

.... A guess I had but turned out to be wrong...
where userfield = forms![parentform_name].[subform_name].
[textbox_name]

The textbox in the subform is a tabular display of
information. That is I don't know how many lines of data
will be displayed ahead of time. In the earlier version
using the listbox, there was garunteed to be a fixed
number of lines of data.


Any help would be appreciated.
Drabbacs
 
You have to refer to a control on a subform with using
SubFormName.Form.ControlName where SubFormName is the name
of the control on the parent form containing the subform.

So you could try

WHERE userfield = Forms!
ParentName.SubFormName.Form.ControlName

Rod Scoullar
 
Nope that didn't work. It asks for a parameter, meaning it
doesn't know what I'm refereing to in my where clause.

I think you may have thought the control is on the
parentform ("where SubFormName is the name of the control
on the parent form"). That's not the case. The control I
want to capture is contained on a subform which in turn is
contained on a parentform.

My other guess is that because this is a tabular form,
there is no way to capture where the user is double
clicking.

When I say tabular form I mean when you use a wizard to
create the form and you specify the source query or table
and then you choose tabular format.

Drabbacs
 
Where Userfield = forms!frmMain!sfrmSub.form![listbox_name]

Note that 'sfrmSub' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmSub.
 
Bingo! Thankyou so much. That worked just fine.


-----Original Message-----
Where Userfield = forms!frmMain!sfrmSub.form! [listbox_name]

Note that 'sfrmSub' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmSub.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I asked this question in an earlier post but the reply was
less than helpful.

If I want to write a query based on a double click event
on a tabular-textbox contained in a subform contained in a
parent form, how would the WHERE clause be phrased?


To compare, in an earlier version of my database, I had a
form that contained a listbox, which displayed several
lines of data. The user could select a particular line and
doubleclick and this would execute a macro/query which
opened another form and diplayed details concerning the
selected line. That was accomplished using the bound
column property in the listbox and the on_dbl_click event.
The macro/query had a where clause something like...

Where userfield = forms![form_name].[listbox_name]

I want to do the same thing with this textbox in the
subform in the form. How do I write the where clause?

... A guess I had but turned out to be wrong...
where userfield = forms![parentform_name]. [subform_name].
[textbox_name]

The textbox in the subform is a tabular display of
information. That is I don't know how many lines of data
will be displayed ahead of time. In the earlier version
using the listbox, there was garunteed to be a fixed
number of lines of data.


Any help would be appreciated.
Drabbacs

.
 
Back
Top