Link to home
Start Free TrialLog in
Avatar of Fred Webb
Fred WebbFlag for United States of America

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.
Avatar of Surone1
Surone1
Flag of Suriname image

Private Sub comboboxeBox_AfterUpdate()

me.filter = "CUSTNMBR = " & combo.text

end sub
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
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
Avatar of Fred Webb

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
Avatar of Surone1
Surone1
Flag of Suriname image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
Would I put that code on the  on Click () event property?
afterupdate, on click might work too
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial