Access 2007 Listbox on forms

gcarpent

New member
Local time
Today, 12:59
Joined
Dec 8, 2011
Messages
2
I would like to say what a great contribution to society this forum is, bless you all. I have an Access 2007 form with a combo box named Combo62 that get records from SAPDels Customer field, I also have a listbox that gets its records from SAPDels TrnsIDCode field, the listbox list all the fields in SAPDels and highlights the correct field when a record in displayed, when I select a customer from Combo62, it filters the form to the records associated with that Customer, but the listbox doesn't update to show only the fields that are associated with that customer. Can you pleae help me, thanks in advance....
 
you need to base your listbox on a query. Then when you make a selection in your combo box you can use this function to retrieve your selection and place it in the criteria of your query. Put this code in a module. Then in your query in criteria under the field your filtering on type: fCboSearch(Forms!FormName.ComboboxName)

Code:
Public Function fCboSearch(vCboSearch As Variant)

    If IsNull(vCboSearch) Or vCboSearch = "" Then
        fCboSearch = "*"
    Else
        fCboSearch = vCboSearch
    End If
    End Function

Lastly, for your combo box, select the after update event--->event procedure, then type Me.ComboboxName.Requery
 
BBQ Kittens, you are awesome, thanks a million, I was missing the REquery in the afterupdate event. I can't thank you enough....
 

Users who are viewing this thread

Back
Top Bottom