problems on link childfield with Listbox

G

Guest

Hi,
I have a subform with link master on a listbox. It works perfectly
(when an item -pk is selected in the listbox, data in corresponding record is
retrieved and populated into subform). However, it doesn't work under the
following scenario:
I have a command button which adds new items into listbox (since that a
new entry - therefore no record is associating with that pk). When that's
clicked it 1) runs SQL statement to add that record into table and add the
new item (autonumber) into listbox -which works fine. 2) set listbox selected
item to true
ListBatch.Selected(ListBatch.ListCount - 1) = True -- which also works.
However, the subform is not updated (it stays on the whatever selected
previously). If I clicked on the selected item, then the correct data is
populated.
It seems like highlighting a listbox item is not as same as clicking it.
Can someone please tell me how can I work around it?

Thanks
 
D

Dirk Goldgar

Jeff said:
Hi,
I have a subform with link master on a listbox. It works
perfectly (when an item -pk is selected in the listbox, data in
corresponding record is retrieved and populated into subform).
However, it doesn't work under the following scenario:
I have a command button which adds new items into listbox (since
that a new entry - therefore no record is associating with that pk).
When that's clicked it 1) runs SQL statement to add that record into
table and add the new item (autonumber) into listbox -which works
fine. 2) set listbox selected item to true
ListBatch.Selected(ListBatch.ListCount - 1) = True -- which also
works. However, the subform is not updated (it stays on the
whatever selected previously). If I clicked on the selected item,
then the correct data is populated.
It seems like highlighting a listbox item is not as same as
clicking it. Can someone please tell me how can I work around it?

Thanks

Don't set the Selected property. Set the Value property of the list box
to the pk of the new record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top