Group: microsoft.public.access.forms
From: JWOL
Date: Tuesday, October 23, 2007 8:10 AM
Subject: Re: List box values not changing on sub-form

On Oct 23, 12:32 pm, "Douglas J. Steele"
wrote:
> Try issuing a Requery whenever you change records on the main form.
>
> In the form's Current event, you'll want something like:
>
> Private Sub Form_Current()
>
> Me!SubformControl.Form!ListboxOnSubform.Requery
>
> End Sub
>
> Note that depending how you added the subform to the main form, the name of
> the subform control on the parent form may not be the same as the name of
> the form being used as a subform.
>
> --
> Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
> (no e-mails, please!)
>
> "JWOL" wrote in message
>
> news:1193137116.335280.245430@z24g2000prh.googlegroups.com...
>
>
>
> > Hi,
>
> > I have a list box on a sub-form which has a query as its row source.
> > What I am trying to do is have the list box display child records that
> > are linked to their parent record which is displayed on a main form.
> > So the main form, for example, contains a person's name and address
> > then the sub-form displays the details of one of their children. The
> > list box should display details of all of their children and if one of
> > the records in the list box is clicked on, the details should then be
> > displayed in the sub-form. I have managed to get the child record
> > displayed in the list box but as I move through the parent records on
> > the main form, the values in the list box do not change. It just
> > shows the first record in the child table and then never changes.
>
> > I've tried a couple of different queries but I'm not sure that the
> > query is the problem. Could there be something in the list box
> > properties that needs setting? I'm fairly new to Access so I could be
> > missing something really obvious but it's not obvious to me. These
> > are the queries that I've tried so far:
>
> > SELECT field1, field2 FROM tableA JOIN tableB ON tableA.ID = tableB.ID
> > WHERE forms!mainform!ctrl_ID = forms!subform!ctrl_ID
>
> > (the above one causes a popup box to appear asking for a value for
> > forms!subform!ctrl_ID)
>
> > SELECT field1, field2 FROM tableA JOIN tableB ON tableA.ID = tableB.ID
> > WHERE forms!mainform!ctrl_ID = tableB.ID
>
> > (the above query is the one that just shows one record in the list box
> > and then it never changes)
>
> > I've made the two ID controls on the main form and the sub-form
> > visible so that I can see the values are changing as the records
> > change. The first query seems correct to me but the popup box means
> > that it probably isn't.
>
> > Any help appreciated.- Hide quoted text -
>
> - Show quoted text -

By the way, how do I then get the sub-form to show the new values of a
record selected in the list box?