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:
Function isn't available in expressions
When you click More Help in the error message box, you also receive the
following error
The topic does not exist. Contact your application vendor for an
updated Help file. (129)
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.