listbox backwards sync

G

Guest

I have a need to do 2 things in relation to my list box

1) Like in a combo box I want to enter the letters ie Smith and have it move
down the listbox within the "S" rather than go from the "s's" to the "m's"
etc. Is there a way to write vba to do that?

When an item is chosen from the list box the following code is executed...
this works fine.
On Error GoTo Err_List34_AfterUpdate
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[VolunteerID] = " & Str(Nz(Me![List34]))

If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Exit_List34_AfterUpdate:
Exit Sub

2) I have a search on the form as well. What I want to do when it finds the
record is sync the list box to the record shown. Is there a way to do that?
 
S

storrboy

I have a need to do 2 things in relation to my list box

1) Like in a combo box I want to enter the letters ie Smith and have it move
down the listbox within the "S" rather than go from the "s's" to the "m's"
etc. Is there a way to write vba to do that?

This will require some doing. Place a textbox near (usually above) the
list box. Use the OnChange event of the textbox so that the checking
of a match occurs with each character typed in. You'll need to scan
through the appropriate column of the list box and look for an entry
that is starts with the same characters. If found set that list item
to Selected = True, otherwise it's not found and the posistion of the
list box dosen't change.
2) I have a search on the form as well. What I want to do when it finds the
record is sync the list box to the record shown. Is there a way to do that?

Usually you'd set the recordsource (or filter) of the form/subform to
a query that uses the listbox as a criteria value. WHERE table.field =
" & ListBox. Exact syntax depends on datatypes and query structure.
 

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