totn Access

MS Access 2003: Filter a query based on InputBox command

This MSAccess tutorial explains how to filter a query based on an InputBox command in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, I want to be able to filter a query using the InputBox command. The InputBox should ask the user to enter a Number which will be used in the query. Is this possible?

Answer: To use the InputBox command in a query, you will need to create a function. We always prefer to create our functions in an Access module so that the function is accessible from the entire database.

Download version in Access 2000 (as demonstrated below)

First, we've created a function in Module1 that is called GetParmValue. This function returns the value entered by the user (via the InputBox command).

Next, we've referenced the function in the query. See picture below.

Microsoft Access

When the query above is run, the following prompt will appear.

Microsoft Access

The user will enter a Number and click on the OK button. The query will then return the rows where the OrderID field equals the value entered by the user.