Re: list box from query

From: Sandra Daigle (Invalid_at_KeepYourSpam.org)
Date: 08/20/04


Date: Fri, 20 Aug 2004 09:39:04 -0400

Yes! That helps and explains the problem you are having. When you reference
a control which is on a subform you have to include the parent form in the
reference. The syntax of the reference is as follows:

Forms!ParentFormName!SubformControlName.form!ControlName

Where you replace the following:

ParentFormName: with the name of the parent form

SubFormControlName: with the name of the subform control on the parent form.
(Verify by clicking once on the subform to select the subform control, then
check the name property)

ControlName: with the name of the control on the subform

If you were referencing a control on the grandchild form (or sub-subForm)
then the reference would be a tad more complex because you would have to go
through 2 form objects:

Forms!ParentFormName!SubformControlName.form!SubSubFormControlName.form!Cont
rolName

Your control is on the subform so yours won't be quite so bad!

The requery for the listbox needs to occur in the Current event of the
subform. It would look something like this:

me.subSubFormControlName.form!MyListbox.requery

Note that in this statement "me" is referring to the form object of the
first subform since the code will be in the class module of the first
subform. Then "subSubFormControlName" should be replaced with the name of
the grandchild subform control.

-- 
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
andrew wrote:
> Thanks again!
> If this helps, I have three nested forms (say, the parent,
> child, and grandchild)  The listbox is in the grandchild
> form, and is based on a value in the child form.
>
> If I open the form from the parent level, it will ask for
> me to enter the query value.
>
> If I open the form from the child level, it will update
> the grandchild form without a prompt.  But it also will
> not update the query as I switch to a different record
> value on the child field.
>
> The help is appreciated!  Thanks for the time.
> Andrew
>
>
>
>> -----Original Message-----
>> If your reference in the query is correct it shouldn't be prompting
>> you for a value. Make sure that what you put in the query matches
>> the name of the control that has the test value. Select the control
>> and double check the name property (under the 'Other' tab).
>>
>> --
>> Sandra Daigle [Microsoft Access MVP]
>> Please post all replies to the newsgroup.
>>
>>
>> andrew wrote:
>>> Thanks so much for the help!  One thing...when I open the
>>> form, it demands that I manually enter a value.  How do I
>>> get it to look at the value on the parent form?
>>>
>>> Thanks again!
>>> Andrew
>>>
>>>> -----Original Message-----
>>>> Just reference the form control directly in the query.. In the
>>>> query designer put the following in the criteria field of the
>>>> appropriate column:
>>>>
>>>> forms!MyForm!MyControl
>>>>
>>>> Replace 'MyForm' with the name of the form that has the filtering
>>>> value and replace 'MyControl' with the control name.
>>>>
>>>> You may need to requery the listbox using the AfterUpdate event of
>>>> the Control that filters the listbox.
>>>>
>>>> --
>>>> Sandra Daigle [Microsoft Access MVP]
>>>> Please post all replies to the newsgroup.
>>>>
>>>>
>>>> andrew wrote:
>>>>> Hello all!
>>>>> I have a list box (in a subform) that I want to populate
>>>>> from a query.  I need to "send" to the query a value from
>>>>> the parent form.
>>>>>
>>>>> I created the query in design view, where it works when I
>>>>> manually "hard code" the determing value.  How do I get my
>>>>> form to send different values to the query?
>>>>>
>>>>> Thanks!
>>>>> Andrew
>>>>
>>>>
>>>> .
>>
>>
>> .


Relevant Pages

  • Re: Does a textbox have to have a name reference, or can I use a w
    ... for referencing an outside form (that is, not the current form or subform): ... subform control, which is to say the actual form being used as a subform. ... PreviousControl can reference only one control. ... Debug.Print stAppName ...
    (microsoft.public.access.formscoding)
  • Re: Error 2455 (associated with subform reference)
    ... Products combo box in the subform, and to set the criteria for VendorID to ... the main form control. ... The good news is that I don't need to reference subform controls in the ... could probably pass over the error message in the code's error handling, ...
    (microsoft.public.access.formscoding)
  • Re: Referencing problem
    ... Re:> Activecontrol does not return the correct reference for controls ... Dim ctlSpell As Control ... If TypeOf ctlSpell Is TextBox Then ... If the tab is on a subform, ...
    (comp.databases.ms-access)
  • Re: Highlight current record
    ... SubForm.OnCurrent even must fire after the parent form is opened as the first ... The subform is in a SubForm container on a different form as in: ... Forms!ParentForm!LN = Me!LineNumber action is taken in the OnCurrent event. ... control on a continuous form. ...
    (microsoft.public.access.forms)
  • RE: combo box, select all
    ... The code you cited is only appropriate if you are setting the form's Filter ... Also it applies to the parent form not ... the subform, ... the button's Click event procedure is to requery the subform control as I ...
    (microsoft.public.access.gettingstarted)

Quantcast