Fred Webb
asked on
Display records based on combo Box
I have a table that consists of CUSTNMBR, Name, Address, Etc and a simple form based on the table. I would like is to have the records on the form displayed by selecting CUSTNMBR from a combo box. This should be simple but the solution eludes me. Any assistance would be greatly appreciated.
do make sure the combobox's event handler is on for afterupdate in the properties
Private Sub combobox_AfterUpdate()
me.filter = "CUSTNMBR = " & combobox.text
end sub
me.filter = "CUSTNMBR = " & combobox.text
end sub
not sure if that is what you want, since if the combo is bound you would need to change it to unbound and add a procedure to fill it
ASKER
I want to be able to click the dropdown on the combo box, select the customer number and go the record associated with that customer number
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The CUSTNMBR field is populated and is part of the table that populates the form.
if the CUSTNMBR is a textfield it's
Set rs = Me.Recordset.Clone
rs.FindFirst "[CUSTNMBR] = '" & combobox.text & "'"
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
set rs = nothing
Set rs = Me.Recordset.Clone
rs.FindFirst "[CUSTNMBR] = '" & combobox.text & "'"
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
set rs = nothing
if numeric
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CUSTNMBR] = " & combobox.text
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
set rs = nothing
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CUSTNMBR] = " & combobox.text
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
set rs = nothing
ASKER
Would I put that code on the on Click () event property?
afterupdate, on click might work too
ASKER
I think I am missing something, the CUSTNMBR is a text field and currently a text box on the form, would I convert that field to a Combo Box, or create a completely new Combo Box and if so what would be the best way to populate it?
the easiest way is drag a new combobox on the form and use the wizard i guess.. after that you can modify properties/code to your liking..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
me.filter = "CUSTNMBR = " & combo.text
end sub