Using InParam() function provided by Microsoft

RexesOperator

Registered User.
Local time
Today, 11:57
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?
 
InParam() errors

I really would like an answer to this. I have a list box that I want to use to print more than report at a time (see attachment). This seems to be the easiest way to do that. What I am trying to do is for the user to be able to select any number of records and print out the appropriate report. Once I get this part working, there are enough examples in the forum, I think I can get the rest working.
 

Attachments

  • PrintForm.JPG
    PrintForm.JPG
    46 KB · Views: 274
Hi,

MS assumed this "Option Compare Database" by default as included the the module. Put it back.

There are very little details on how you use the buttons to print the reports.
Post the SQL syntax for us to see.

RexesOperator said:
I really would like an answer to this. I have a list box that I want to use to print more than report at a time (see attachment). This seems to be the easiest way to do that. What I am trying to do is for the user to be able to select any number of records and print out the appropriate report. Once I get this part working, there are enough examples in the forum, I think I can get the rest working.
 
Using InParam() function

I got the problem sorted out in another forum. Sorry I didn't post the SQL for you to look at. The problem was that I used the same name for the module as the function.
 

Users who are viewing this thread

Back
Top Bottom