RexesOperator
Registered User.
- Local time
- Today, 11:48
- Joined
- Jul 15, 2006
- Messages
- 604
I'm trying to get the InParam() function provided by Microsoft to work, but without luck, so far. I have searched the forum, but this problem doesn't show up in the searches I have found. I suspect the problem is my implementation.
I copied and pasted the function to a Module named InParam as is, removing the Option Compare Database line (since it is not included in the Microsoft example) :
'************************************************************
'Declarations section of the module.
'************************************************************
Option Explicit
'============================================================
' The GetToken() function defines the delimiter character.
'============================================================
Function GetToken(stLn, stDelim)
Dim iDelim As Integer, stToken As String
iDelim = InStr(1, stLn, stDelim)
If (iDelim <> 0) Then
stToken = LTrim$(RTrim$(Mid$(stLn, 1, iDelim - 1)))
stLn = Mid$(stLn, iDelim + 1)
Else
stToken = LTrim$(RTrim$(Mid$(stLn, 1)))
stLn = ""
End If
GetToken = stToken
End Function
'============================================================
' The InParam() function is the heart of this article. When
' the query runs, this function causes a query parameter
' dialog box to appear so you can enter a list of values.
' The values you enter are interpreted as if you
' had entered them within the parentheses of the In() operator.
'============================================================
Function InParam(Fld, Param)
Dim stToken As String
'The following two lines are optional, making queries
'case-insensitive
Fld = UCase(Fld)
Param = UCase(Param)
If IsNull(Fld) Then Fld = ""
Do While (Len(Param) > 0)
stToken = GetToken(Param, ",")
If stToken = LTrim$(RTrim$(Fld)) Then
InParam = -1
Exit Function
Else
InParam = 0
End If
Loop
End Function
The query I am using has two fields (to be expanded once this works): FileNumber and TransactionsID.
I want the function to work on the FileNumber field (datatype long integer), thus
InParam([FileNumber],[Enter list using commas, no spaces:])
I get a syntax error in the query: The expression you entered contains invalid syntax.
I also tried changing the dataype of FileNumber to text, and get this message: Undefined function in 'InParam' in expression.
What have I done wrong?
I copied and pasted the function to a Module named InParam as is, removing the Option Compare Database line (since it is not included in the Microsoft example) :
'************************************************************
'Declarations section of the module.
'************************************************************
Option Explicit
'============================================================
' The GetToken() function defines the delimiter character.
'============================================================
Function GetToken(stLn, stDelim)
Dim iDelim As Integer, stToken As String
iDelim = InStr(1, stLn, stDelim)
If (iDelim <> 0) Then
stToken = LTrim$(RTrim$(Mid$(stLn, 1, iDelim - 1)))
stLn = Mid$(stLn, iDelim + 1)
Else
stToken = LTrim$(RTrim$(Mid$(stLn, 1)))
stLn = ""
End If
GetToken = stToken
End Function
'============================================================
' The InParam() function is the heart of this article. When
' the query runs, this function causes a query parameter
' dialog box to appear so you can enter a list of values.
' The values you enter are interpreted as if you
' had entered them within the parentheses of the In() operator.
'============================================================
Function InParam(Fld, Param)
Dim stToken As String
'The following two lines are optional, making queries
'case-insensitive
Fld = UCase(Fld)
Param = UCase(Param)
If IsNull(Fld) Then Fld = ""
Do While (Len(Param) > 0)
stToken = GetToken(Param, ",")
If stToken = LTrim$(RTrim$(Fld)) Then
InParam = -1
Exit Function
Else
InParam = 0
End If
Loop
End Function
The query I am using has two fields (to be expanded once this works): FileNumber and TransactionsID.
I want the function to work on the FileNumber field (datatype long integer), thus
InParam([FileNumber],[Enter list using commas, no spaces:])
I get a syntax error in the query: The expression you entered contains invalid syntax.
I also tried changing the dataype of FileNumber to text, and get this message: Undefined function in 'InParam' in expression.
What have I done wrong?