Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box record number not updating

Status
Not open for further replies.

simon1974

Technical User
Apr 2, 2002
43
US
Here is my scenario:

I have two list boxes. One is populated from a "total population" table. One is populated from a "selected population" table. I have VBA code that adds the record from ListBox1 (Total Population) to the recordsource for ListBox2 (Selected Population)and refreshes the form so that the new record is populated in ListBox2. The form record source is the same as that of ListBox2. I have ListBox2 set up to "find the matching record on the form." This way I can run the record delete procedure when I click on a row in the listbox and it will delete that record from the underlying table. The problem is that when I click on the records I have added while the form has been open, the listbox navigates the form to record 1 in the table. If I close and reopen the form, the listbox trues itself up, but I am looking for a way to accomplish this without closing and opening the form. Thanks.

Sean
 
try the following....

in the afterupdate event for listbox2 (maybe listbox1 after the code to update listbox2), put:

Me.Requery
Me.Refresh

This will force the form to check the listox2 recordsource and update its recordsource. The refresh then forces the form to update all the fields visible on the form....

hope this helps. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top