How to set combo box to value as determined by listbox column?

madEG

Registered User.
Local time
Today, 18:53
Joined
Jan 26, 2007
Messages
307
I'm sorry if this has been asked before... Perhaps I don't know what terms to search for what I mean - I kept finding great answers to different questions. :)

In short, I have a form that has a combo box containing people type values. Then two text entry boxes, firstname, lastname. Then an add, update, and delete button...

When the person type is chosen from the cbo, and the names are filled out, and the 'add' button pressed a query sends the values back via sql insert, and a listbox next to these controls then lists the new person records. Great - No worries...

Then, when someone wants to update the record now shown in the listbox, on double click of the record in the listbox, vba repopulates the name text boxes from the listbox's columns values (easy), and then *magically* the person type combo box chooses amongst its values the value stored in the person type column from the listbox.

I can't get the combo box to be set to the value that I am grabbing from the listbox's column values.

Code:
cboContactInfoType.{magic happens here} = ListBoxOfficeContactInfo.Column(3)
txtContactInfoValue = ListBoxOfficeContactInfo.Column(4)
txtContactInfoValue2 = ListBoxOfficeContactInfo.Column(5)

Part of me wonders if I would have to program in a way to search among the combo boxes values and find out which one was selected from the listbox, find it's index value and then set the combo box to be that index/value record... but that seems like a hard way to do it... and I'm not exactly sure how?

Can someone push me in the right direction?

Thanks!
-Matt G.
 
Can you post your database, or a version with no confidential info, but enough to illustrate the issue?
 
Attached is a simple two table db with form illustrating what I can't figure out...

When double clicking on the recors in the listbox, I can't get the cbo to take the value from the column in the listbox.

Thanks!

-Matt G.
 

Attachments

Remember, each box has many options, the value, the back color, the column, etc and you need to assign the list box number to the specifice characteristic. Try this:
cboContactInfoType.value = ListBoxOfficeContactInfo.column(3)
to get the box to display that record, enter:
cboContactInfoType.requery
This is all predicated on the assumption that the bound column of the combo is the number coming from the list box
 
DAWWWWW! The requery on the cbo!!! :)

Thank you!
 
Two hours later I'm still thinking about this. :)

I guess in my head 'requery' was to reload a listbox or browse window, perhaps the options/items for a cbo...

This makes me wonder if one set a listbox's bound column value to whatever, and then requery'd - would the listbox reload *and select that record* with the bound column/id for that listbox?
 

Users who are viewing this thread

Back
Top Bottom