Link to home
Start Free TrialLog in
Avatar of birdn
birdnFlag for United States of America

asked on

Using a combo box to search a form.

Hi everyone,

I have one table with a number of customer records.  One field is a phone number.  I would like to input a phone number into a combo box and have it search the form then display all the records that match the phone number in the subform.

For instance, if I type in (111) 111-1111 the subform should supply all the instances that those records occur.  I’ve included a sample database but I don’t know how to link the combo box to the table and have the records appear in the subform.

Any help would be appreciated.
Thanks.
Database1.accdb
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America 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
Avatar of birdn

ASKER

Works like a charm.  Do you mind explaining the VB cod a bit?
Thanks again for the quick response.
Hello Team,

Me too Having similar issue. However, Instead of Subform, i am using Split Form.
I and trying to filter split form based on Fields, combined with text fields as well as combo box.
To be specific, i am attaching herewith screen shot of the form.

Below query results Zero Records. I am new to SQL and taken some help from here and there ...



Private Sub cmdSearch_Click()
'Show filtered  Records
Dim task As String
    task = "SELECT Val((select NZ(sum(tbllifting.[Lift_qty]),0) from tbllifting where tbllifting.[Sale_BN] = tblsale.[Sale_BN])) AS Lifted, "
    task = task + "[Sale_Qty]-Val((select NZ(sum(tbllifting.[Lift_qty]),0) from tbllifting where tbllifting.[Sale_BN] = tblsale.[Sale_BN])) AS Unlifted, "
    task = task + " * FROM tblsale WHERE"
    task = task + "[Customer] Like '*" & txtCustomer & "*' AND "
    task = task + "[Product] Like '*" & txtProduct & "*' and  "
    task = task + "[PO_No] Like '*" & txtPO & "*' AND "
    task = task + "[Storage] = ' " & cboPort.Column(0) & " '"
    task = task + "ORDER BY tblsale.Deal_Date DESC "

Me.RecordSource = task

End Sub

Guidance will be helpful.
PS : There may be some Blank records in field Storage (cboPort)
Thanks in advance.
2017-05-17.png