J
Jeremy Saul
What I really wanted to do was have a master and sub-form both in continuous
mode, but Access does not allow this, so I have an unbound form with two
unbound list boxes. Both are populated from queries where there is a common
field used by both list boxes. When I select a record in the first list box
I want to display data in the second list box which is filtered from the
query using the common field.
I have achieved this using a hidden text box to store the common field and
using this value in the WHERE clause of the query for the second list box.
In the OnClick event of the first box I read the value from the list box and
update the hidden text box and then requery the second list box. I want to
select the first displayed record by default in the second list box and I
have done this by placing the following in the OnClick event of the first
list box:
lstbox2.requery
if lstbox2.listcount<>0 then
lstbox2.selected(0)=TRUE
end
This seems to work from a display point of view, but is causing a lot of
problems. I have a command button on the form that launches a separate modal
form that is populated from the selected record in the first list box (I
want to change some of the fields in the selected record). Depending on the
sequence in which I select records in the two list boxes the form seems to
get locked up in a strange way. Sometimes when I click on the command button
just the hourglass appears until I release the button - the same is true if
I try to select any other control except the first list box. I have found
that what is happening is that when I click on the command button (or any
other control) the OnClick event procedure of the second list box is being
fired. If I comment out the one line "lstbox2.selected(0)=TRUE" above then
everything works fine, just I am not getting a selection in the second list
box. This locked condition even seems to persist if I close the form and
reopen it.
Could someone suggest a reason for this and what I need to do to correct it.
Is using "selected(0)=TRUE" correct? I never reset this value and sometimes
when I click on the command button two records in the second list box are
displayed highlighted until I release the button.
Jeremy Saul
mode, but Access does not allow this, so I have an unbound form with two
unbound list boxes. Both are populated from queries where there is a common
field used by both list boxes. When I select a record in the first list box
I want to display data in the second list box which is filtered from the
query using the common field.
I have achieved this using a hidden text box to store the common field and
using this value in the WHERE clause of the query for the second list box.
In the OnClick event of the first box I read the value from the list box and
update the hidden text box and then requery the second list box. I want to
select the first displayed record by default in the second list box and I
have done this by placing the following in the OnClick event of the first
list box:
lstbox2.requery
if lstbox2.listcount<>0 then
lstbox2.selected(0)=TRUE
end
This seems to work from a display point of view, but is causing a lot of
problems. I have a command button on the form that launches a separate modal
form that is populated from the selected record in the first list box (I
want to change some of the fields in the selected record). Depending on the
sequence in which I select records in the two list boxes the form seems to
get locked up in a strange way. Sometimes when I click on the command button
just the hourglass appears until I release the button - the same is true if
I try to select any other control except the first list box. I have found
that what is happening is that when I click on the command button (or any
other control) the OnClick event procedure of the second list box is being
fired. If I comment out the one line "lstbox2.selected(0)=TRUE" above then
everything works fine, just I am not getting a selection in the second list
box. This locked condition even seems to persist if I close the form and
reopen it.
Could someone suggest a reason for this and what I need to do to correct it.
Is using "selected(0)=TRUE" correct? I never reset this value and sometimes
when I click on the command button two records in the second list box are
displayed highlighted until I release the button.
Jeremy Saul