# Access 2003 Sql User Input Question



## captainbriggs (Jun 18, 2008)

Hi, I am very new at this. I have an SQL Query in Access 2003 and I
want it to ask me the search parameters (user input) when I open the
query, or when I open a report based on the query. For example, when
I open it, it should pop up a dialog that asks "List boxes in what
location?", then whatever I type there should replace *office* in the
following code:


****************************************************************************************************************
SELECT DISTINCT
BOXES.[Box Number],
BOXES.[Destroy After],
BOXES.[Box Location/Status],
BOXES.[Date Destroyed],
NULL AS [Case Name],
NULL AS [Case Number],
NULL AS [Folder Number],
NULL AS [Folder Description],
NULL AS [Internal File Number]
FROM BOXES
WHERE BOXES.[Box Number]
NOT IN (SELECT DISTINCT [Box Number] FROM [MAGLLP CASE FILES] WHERE
[Box Number] IS NOT NULL)
AND BOXES.[Box Location/Status] LIKE '*office*'

UNION ALL SELECT DISTINCT
BOXES.[Box Number],
BOXES.[Destroy After],
BOXES.[Box Location/Status],
BOXES.[Date Destroyed],
[MAGLLP CASE LIST].[Case Name],
[MAGLLP CASE LIST].[Case Number],
[MAGLLP CASE FILES].[Folder Number],
[MAGLLP CASE FILES].[Folder Description],
[MAGLLP CASE FILES].[Internal File Number]
FROM ([MAGLLP CASE FILES]
INNER JOIN [MAGLLP CASE LIST] ON [MAGLLP CASE FILES].[Case Name] =
[MAGLLP CASE LIST].[Case Name])
INNER JOIN BOXES ON [MAGLLP CASE FILES].[Box Number] = BOXES.[Box
Number]
WHERE BOXES.[Box Location/Status] LIKE '*office*'
ORDER BY BOXES.[Box Number];
****************************************************************************************************************

Can anyone help me with this? Thanks! - Matt


----------



## David M58 (May 20, 2008)

Here's one way to do it. In the SQL you posted, replace this text:

LIKE '*office*'

with this text:

LIKE '*'&[List boxes in what location?]&'*'

When the query runs, Microsoft Access prompts you to enter a parameter value, displaying the question "_List boxes in what location?_" in the dialog.


----------

