Solved

Using a combo box to search a form.

Posted on 2017-05-16
3
32 Views
Last Modified: 2017-05-17
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
0
Comment
Question by:birdn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
test this
--changed the row source of the combo box
--add codes to the afterupdate event of the combo box to filter the subform
db_29023186_filtering.accdb
1
 

Author Closing Comment

by:birdn
Works like a charm.  Do you mind explaining the VB cod a bit?
Thanks again for the quick response.
0
 

Expert Comment

by:Kamlesh Jain
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
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Join & Write a Comment

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question