Query uses textbox value in criteria - need to add wildcard (1 Viewer)

malxvc

Registered User.
Local time
Today, 02:13
Joined
Sep 12, 2012
Messages
21
-Using MS Access 2003-

I have a command button set up to execute a select query. The select query performs the search based on the criteria entered in a text box.

Here is how it looks in query design view:

Field: AccountNumber
Table: CustomerTable
Criteria: [Forms]![Form1]![txtAccountNumber]

In some instances, only a portion of the account number will be available to the user, so in order for this query to work, I need to the query to look for the number entered and any values before and after it.

ex: The actual account number is 115468551621824.If the user enters 55162 in the textbox, I want the query to return the actual account number.

I assume it's just a simple insertion of * before and after [txtAccountNumber], but I'm guessing there are more characters to enter around the asterisk to clarify that it is to be treated like a wildcard.

I figure this is a pretty common question, and I apologise for flooding the board with it, but being new to Access, I am not too familiar with the jargon, and have had a hell of a time searching for a solution.

Thanks in advance to anyone who helps.
 

malxvc

Registered User.
Local time
Today, 02:13
Joined
Sep 12, 2012
Messages
21
The wildcard portion with the "*" is exactly what I was looking for, but I do not understand what the proceeding OR portion is doing.

Perhaps I should have mentioned that this select query is populating a subform based on the value entered in the textbox, which is querying on a table with thousands of records. Entering that code into the query's criteria automatically displays every record since the wildcard on the NULL value in the textbox will return every record with a character in the AccountNumber field. Ideally, the subform is to remain blank until the textbox value is entered and the command button is clicked.
 

Users who are viewing this thread

Top Bottom