Using multiple parameters with Inparam

PAH

New member
Local time
Today, 01:16
Joined
May 29, 2002
Messages
5
I am running a query that uses the InParam function described multiple times on this site to allow users to choose multiple choices from a field on my table being queried.
My problem comes if I add a second user input criteria.
If I add a second user input For example between[Start Date?] and [End Date?] The query doesn't work.
If i try and link the date criteria off a form to get it's date range -- same thing. But -- I CAN put in hard coded Criteria (as in permanent - no user input) and it works.
Can't find a way around this.
The error says Too Few Parameters. Expected (and then either a zero or a One)

HERE is is in SQL

SELECT JobDetailMainTable.JobNumber, JobDetailMainTable.Code, JobDetailMainTable.DownHrs, InParam(
Code:
,[Enter Code#'s Separated By Comma]) AS Expr2, JobDetailMainTable.MachNum, JobDetailMainTable.runDate
FROM JobDetailMainTable
WHERE (((InParam([Code],[Enter Code#'s Separated By Comma]))=True) AND ((JobDetailMainTable.MachNum)<954) AND ((JobDetailMainTable.runDate) Between [Enter Start Date Range] And [Enter End Date Range]))
ORDER BY JobDetailMainTable.Code, JobDetailMainTable.MachNum;
 
That article confused me to no end.
Why would the query work if I used multiple user input parameters, but fail if I used the InParam() "function" in my query?
I've been trying to think of several different ways to allow me to use a form for the input without having to instruct users on all the syntaxes for entering their parameters. such as #'s around dates, _or_ , etc....
Nothing so far though.
 
Hmmm. Not sure what is going on for you so try this as it works for me. I use a Multiselect list box for my InParm() criteria and I have an unbound text box on the same form. The user selects the items they want from the list box and input the criteria in the unbound control and click a button. The query returns the records that meet the criteria. The list box concatenates the selections made and saves the string in a hidden control from which the InPram() function gets its data.

This is what my Where clause looks like:

WHERE (((tblData.FirstName)=[Forms]![frmDemo]![FirstName]) AND ((InParam([Color],[Forms]![frmDemo]![Text3]))=True))

hth,
Jack
 
I'll try that, but I'm posting this Even before trying.
I used a list box on a form which allowed you to choose multiple items. I then used a command button to "send" it to a text box also inserting the OR in between each. I then used the text box to reference for the Criteria in the Query, but it didn't work because of formatting issues. If I chose just one Code (these are numbers by the way - not text) then it worked.
 
If you are trying to use multiple Or's and then toss in an And as another criteria that may be your problem. You have to be sure you have your And's and Or's set up correctly or you will get nothing.

Also, the InParm() uses commas between criteria, but I think you are aware of this.

Jack
 
You can't use OR or AND in the parm string. Your function should simply return a list of values separated by commas. The values should also be surrounded by quotes if they are text.

(4,5,9)
Or
("A","D","G")
 

Users who are viewing this thread

Back
Top Bottom