Article ID: 164239
Article Last Modified on 1/19/2007
APPLIES TO
- Microsoft Access 97 Standard Edition
This article was previously published under Q164239
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you use the InputBox() function in a query, you may receive the following error message:
When you click More Help in the error message box, you also receive the following error
RESOLUTION
The following four methods enable you to work around this behavior.
Method 1: Use a Parameter
You can use a parameter in the query in place of the InputBox() function. For example, instead of the expression
InputBox("Enter a Date")
use the parameter:
[Enter a Date]
Then on the Query menu, click Parameters and type the parameter again, along with its associated data type, in the Query Parameters dialog box.
For more information about parameter queries, search the Help Index for "parameter queries."
Method 2: Use the Eval() Function
You can wrap the InputBox() function inside the Eval() function. Use two sets of quotation marks (") or one set of apostrophes (') around each of the text arguments for the InputBox() function. For example, instead of the expression
InputBox("Enter a Date","Title",#1/1/95#)
use the expression:
Eval("InputBox(""Enter a Date"",""Title line"",#1/1/95#)")
-or-
Eval("InputBox('Enter a Date','Title line',#1/1/95#)")
Method 3: Use the Query by Form Technique
If the information you want to type in the input box can be obtained from a form, you can use the query by form technique to supply the criteria. For example, instead of the expression
InputBox("Enter a Date")
use the expression:
Forms![Form Name]![Control Name]
For more information about using the query by form technique, search the Help Index for "query by form," and see the following article in the Microsoft Knowledge Base:
95931 ACC: How to Use the Query-by-Form (QBF) Technique
Method 4: Use the InputBox() Function in a Custom Procedure
Create a custom procedure that contains the InputBox() function, and then use the custom procedure in your query. For example, instead of the expression
InputBox("Enter a Date","Title",#1/1/95#)
use the expression:
GetDate()
where GetDate() is the following custom procedure in a module:
Function GetDate() GetDate = InputBox("Enter a Date","Title",#1/1/95#) End Function
For more information about creating a custom procedure, please see the Microsoft Access manual, "Building Applications with Microsoft Access 97," Chapter 2, "Introducing Visual Basic," pages 57-81.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
- Start Microsoft Access and open the sample database Northwind.mdb.
Create a new query in Design view based on the Orders table:
Query: ListOrders ----------------------------------------------------- Type: Select Query Field: OrderID Table: Orders Field: CustomerID Table: Orders Field: OrderDate Table: Orders Criteria: InputBox("Enter a Date","Title",#1/1/95#)
- On the Query menu, click Run. Note that you receive the error message. Click More Help in the error message box and note that you receive the second error message.
REFERENCES
For more information about the InputBox() function, search the Help Index for "InputBox function," or ask the Microsoft Access 97 Office Assistant.
Additional query words: function isn t available in expressions
Keywords: kberrmsg kbprb KB164239