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

Populate combo box based on the lookup results

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I have a configuration table.

Model Select Code
1 WYSE-2
1 WYSE-22
1 WYSE-333
2 NEXI-123
2 NEXI-345


What I want to do is when user fills out the form, once he's chosen a value 1 as a Model, the combo box for select code populates with all those three select codes available for Model 1

Please help

Thanks
 
I use this type of thing with a combo and a listbox, selecting a value in the combo sets the rowsource of the list box using SQL.
You could do similar in your case.

Private Sub cboCustomer_AfterUpdate()
'If selection is made in cboCustomer
If cboCustomer.ListIndex > -1 Then
'Call mLoadCreditList and pass the CustomerID from cboCustomer
mLoadCreditList cboCustomer
End If
End Sub

Private Sub mLoadCreditList(ByVal vlngCustomerID As Long)
Dim strSQLCreditAgmts As String
'SQL to select all records from tblCreditAgreement where
'CustomerID is equal to the CustomerID of the selection in the
'cboCustomer (ie. vlngCustomerID in this case)

strSQLCreditAgmts = "SELECT * FROM tblCreditAgreement " & _
"WHERE CustomerID = " & vlngCustomerID

'Set the row source of the list box to our selection

lstCreditAgreement.RowSource = strSQLCreditAgmts

End Sub There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top