By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Update form when list selection changes

P: n/a
I have a form that has a textbox used to search records in a table. On
the form I have a listbox which shows each record in the table. When
you click on each row in the listbox the rest of the form updates to
show the other fields in the table.

The problem I am having is when I enter text to search the table the
list narrows successfully, but the rest of the information still
reflects the first record in the table. When I click on one of the rows
in the listbox the rest of the form shows the correct information, but
I would like to have the form update when the selections in the listbox
are narrowed.

For example the listbox shows Row1 and Row2. Row 1 is the current
record in the table and the entire form shows that record. I type
"Row2" in the search box and click a command button that requeries the
listbox. The listbox now only shows Row2, but the rest of the form
still shows data for Row1. When I click on Row2 in the list (this is
the only choice) the form updates and shows the data for Row2. I can't
seem to be able to get the form to update so the first row is selected
and the rest of the form reflects the change.

May 11 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Brian wrote:
I have a form that has a textbox used to search records in a table. On
the form I have a listbox which shows each record in the table. When
you click on each row in the listbox the rest of the form updates to
show the other fields in the table.

The problem I am having is when I enter text to search the table the
list narrows successfully, but the rest of the information still
reflects the first record in the table. When I click on one of the
rows in the listbox the rest of the form shows the correct
information, but I would like to have the form update when the
selections in the listbox are narrowed.

For example the listbox shows Row1 and Row2. Row 1 is the current
record in the table and the entire form shows that record. I type
"Row2" in the search box and click a command button that requeries the
listbox. The listbox now only shows Row2, but the rest of the form
still shows data for Row1. When I click on Row2 in the list (this is
the only choice) the form updates and shows the data for Row2. I can't
seem to be able to get the form to update so the first row is selected
and the rest of the form reflects the change.


In the code that you run that updates what is shown in the ListBox add the
line...

Me!ListBoxName = Me.ListBoxName.Column(0,0)

Assuming that the ListBox has only one column and no ColumnHeadings showing.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 11 '06 #2

P: n/a
Rick, thanks for your help. I put that code in my command button, and
it does make the first row in my list hilighted, but the data in the
rest of the form still does not reflect the change until I actually
click on the already hilighted row. I tried looking at the clicked
event for the list, but the only code that shows up is code that I put
in there for other functions. Is there a way to force an update by
triggering the clicked event for the list?

May 12 '06 #3

P: n/a
Brian wrote:
Rick, thanks for your help. I put that code in my command button, and
it does make the first row in my list hilighted, but the data in the
rest of the form still does not reflect the change until I actually
click on the already hilighted row. I tried looking at the clicked
event for the list, but the only code that shows up is code that I put
in there for other functions. Is there a way to force an update by
triggering the clicked event for the list?


Sorry I forgot about that. Update events for form controls do not fire if the
control's value is changed from code, only if by the user via the GUI. You just
need to call your ListBox's event procedure from the button code. For instance
if you are using the AfterUpdate event of the ListBox...

Me!ListBoxName = Me.ListBoxName.Column(0,0)
Call ListBoxName_AfterUpdate

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.