Moving to an Item in a listbox when opened.

Eightball

New member
Local time
Today, 12:46
Joined
Nov 17, 2002
Messages
9
First of all let me say thanks to everyone.

I am trying to open a form with a listbox on it. When the form opens the listbox moves to the closest matching record based on a value in a previous form. Is there an easy way of doing this?

Thanks.
Eightball
 
Can you get your form to open at the correct record?

If so try fiddling with the following code to set the 'black' bit of the listbox


Dim ListPosition as Integer

ListPosition = Your Criteria '(Maybe ID or the criteria that selects the record like Me.CurrentRecord

Me.ListBox.Selected(ListPosition) = True

Substitute ListBox with the name of your listbox.

HTH
Dave
 
Thanks Dave,
I basically want the listbox to act like a combobox except the listbox looks at the first character in the previous form's field, moves to the first matching record, then looks at the second character, and if possible moves to the first record that matches with the first two characters etc. Kinda like typing in a combobox.

Can I make the listbox a combobox and then loop through the field using the mid method and then simulate typing it in by using the sendkeys command?
 
Not sure of what you're trying to achieve here. Is the listbox on the newly opened form or the form that opens the second form?

I made a search thing for work once to quickly narrow down searches.

Check the attachment and type in the 'Supplier of' field. Each time you type a letter the subform requeries, narrowing down the no in the list.

Then double clicking the record selector on the LHS of the record displays full details.

Hopefully the code in there may assist is some way.
Dave
 

Attachments

Form1 has a field containing a model number. Pushing a button on form1 opens form2 that contains a listbox with, among other fields, a model number field. The listbox will move to the exact match of the model in the form1 field if possible, otherwise it will move to the closest match possible in the list of model numbers (the most characters of the model number that do match).
Thanks for you help.
 
Well I give up!!! If I try using sendkeys into a combobox my darn NumLocks keeps turning off, plus if I move the mouse it moves the selected item in the box. All I want is a box that acts like a combobox (moving to an item as you type) but the input isn't from someone typing but rather from a field on another form. Isn't this possible???

Thanks again
 
Last edited:

Users who are viewing this thread

Back
Top Bottom