Listbox not selecting first value properly

Help.Chris

Registered User.
Local time
Today, 21:24
Joined
Oct 11, 2000
Messages
43
Hi all,

I have a list box that is required to have the first value autoselected when a combobox's contents are changed.
I have this working using "Me.ClerkList.Selected(1) = True" which works.

I have another listbox based on the selection in the first listbox. This is set to requery at the same time the combobox contents change, though after the selected comand. This is not updating due to the selection in the first listbox not changing properly. The box is highlighting the first row, but if i msgbox the value selected it never changes with the selected row unless i am clicking on the listbox itself.

How can i accomplish this, i need to be able to have the contents of the second listbox change at the same time as the first??? ie.

i change the contents of the combobox, this changes the contents of the first listbox and selects the first value, then the second listbox changes to show the records matching the id of the first listbox.

Thanks for any help!!!

chris
 
Assuming you have set the criteria in ListBox2's rowsource to reference ListBox1 (?), have you tried puuting ListBox2.Requery on the AfterUpdate event of ListBox1?
 
I have put the requery command on the afterupdate command of the first listbox, and this does work, but only when i manually click on the row in the first listbox.

When i change the item in the combobox which populates the first listbox, the contents change in the first listbox but the contents of the second remains the same. I have added a msgbox to the change event on the combo box to show me the id of selected item in the first listbox, this is not changing even though the first item is being selected through the VBA select(0)=true command (which is working and showing shaded over the first line). I think the selected(1)=true command does not change the value in the listbox, but does change what appears to be selected, only clicking on the actual row definately changes the value.

Thanks for any help, very puzzled here????

Chris
 
Post a cut down version with only the required objects and specify Access version.
 
Cutdown version attached

I have attached a cutdown version. I am using Access 2000.

In the version provided, Upon opeing the form, the first item in list box is selected, but the textbox to right of it shows no value is selected until row in listbox is click on.

I am aiming for the id of listbox to change to the first value selected upon chagning the combobox

Thanks for any help provided, is greatly appreciated!!!

Chris
 

Attachments

Just realised, you're from Manchester....

Anything for a fellow Manc :)
 
OK, done it. Have a look at the modified version attached.

Basically I set the unbound text box (intClerkListID) to ItemData(1) of the first List box on FormLoad and ComboChange events.

Upon selecting a different item in List Box 1, the unbound text box will change accordingly.

I then set the rowsource of ListBox2 to reference the unbound text box rather than ListBox1.

Let me know how you go on.
 

Attachments

That is great!!! I can get everything working off that!!! Thanks for your help!!! going to carry on adding the other features, but thanks for your help!!!

Chris
 

Users who are viewing this thread

Back
Top Bottom