J
JWOL
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.
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.