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

select from a combobox using listbox column 5 as criteria??

Status
Not open for further replies.

Event2020

Technical User
Sep 17, 2001
12
GB
Hello,

I am using access2000 and I have a combo box [cmbProduct] on a form that is based on a lookup field [productID] in a table called [tblLines]. I also have on the same form a listbox called [lsbFound] and i want to use column 5 to select from the combo box.

In other words, when the user selects a item in the list box, what ever data is in column 5 is entered into the combo box as if the user was typing it themselves (this would happen on the double click event).

Can anyone tell me how to do this please, thank you for your time.

Event2020
 
Yopu can't just add the Item the user double clicks on into the ComboBox. Your ComboBox is based off a table, so when your user selects that item you need to enter a new record into the table then refresh your ComboBox. You could do this on the double click event. Sample:

Dim rsCombo as Recordset
Set rsCombo = CurrentDb.OpenRecordSet("Name of table for that holds the ComboBox Lookup data", dbopenDynaSet)
rsCombo.Fields(Number of the column that hods the actual data of the ComboBox. Remember Column Numbers start at 0) = lsbFound.SelectedItem
rsCombo.Update
RsCombo.Refresh
rsCombo.Close
Set rsCombo = Nothing

This will add the selected item to the table then update the table and refresh the data in the ComboBox for immediate use.

HTH
 
EXTRA NOTE:
The posted example assumes you only have one column of information in your list box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top