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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating multi-select list box when paging through records

Status
Not open for further replies.

mookie0001

Technical User
Jun 14, 2002
23
US
Hi,

I have a multi-select list box on a form populated by one of my tables. On each load of the form, a VB script is run to select each item in the list box that is present in my table. This works great for the first record. The code I use is --Private Sub Form_Load()-- to launch the script initially.

My problem arrives when I press the next record button to cycle through each page (the default Access buttons at the bottom). I can not figure out how to fire off the script with each page update. Your help is greatly appreciated.

Thanks,
-Chris
 
Hi,
Your listbox after update property should contain something like this, which finds the record that matches your listbox.

Private Sub YourListbox_AfterUpdate()
' This finds the record that matches your listbox selection.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[yourfield] = '" & Me![YourListBox] & "'"
Me.Bookmark = rs.Bookmark
End Sub

You also need the contents of the list box to match the current record you are viewing on your form. Place something like this in the form's Current properties:

Private Sub Form_Current()
YourListbox = [yourfield]

Hope that helps.
 
That solved my problem. Thank you so much!

-Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top