Search Query In Access


New Member
Aug 6, 2008
Morning all, just after a bit of help with an access query.

I have one table with customer data on. I also have a form with text boxes which colleagues type into and it writes to the table. that works ok. I am trying to now create a search so people can go in and see how many times a particular bank account shows up.

I have a drop down combo box with a few selections, bank account, sort code etc. I then have a text box under this so the user can type what they want. So Bank account selected from drop down and 11111111 in text box. I have been trying to create a query which will bring back all the information from the table but which only match that bank account. Or whatever the user picks. So far, no luck getting this to work and am unsure what I am doing wrong. Any advice would be greatly appreciated. I am very new to access so ive basically been teaching myself as I go along so there is probably a better way round this


Active Member
Nov 21, 2019
Office Version
365, 2016
Windows, Web
Hi, let me try to explain all

Table data looks like:

Filter Form looks like:

In this case the combo box have SELECT DISTINCT account FROM tblCustomer in Row Source and Row Type is Table/Query

VBA code for button over On Click Event is:
VBA Code:
Option Compare Database
Option Explicit

Private Sub cmdExec_Click()
DoCmd.OpenQuery "qryAccount", acViewNormal
End Sub
And there is a Query filtered by the form:

When button is pressed, qryAccount is executed, showing only the values correspond the combo box value

Hernan Torres
Mikel ERP


Active Member
Feb 5, 2018
Office Version
365, 2016
Using the technique in welshgasman's video, you can modify it for your dynamic field selector by replacing the SQL "WHERE [Last Name] LIKE " with "WHERE [" & Me.FieldSelector.Value & "] LIKE ".

You would then construct the source of your dropdown to be either a query or a table with the first colum the display name of each keyword field and the second colum the actual name of those fields and bind it to column 2.

Forum statistics

Latest member
Goldi paul

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...