hi,
You are missing a bracket in the last line of your query...so change to ...
Is Null Or [Destination Zip?]="all",[Dest Zip],[Destination Zip?])));
After that, pick a record from the TABLE, and write down the values of a
record as seen in the 3 columns you have parameters on. For example, choose
a record, and write down the value of [Type] for that record. Choose another
record, and write down the value of [Dest ST] for that record. Then choose
another record, and write down the value of [Dest Zip] for that records.
Then run your query, and when prompted type in the 3 values as found in the 3
records respectively. You are guaranteed to get something if your Syntax is
correct, and provided that the name of your TABLE is in the query syntax.
geebee
:
i had a couple fixes i need to make (i put DataTable as a place holder
for longer, complicated table name, and didn't change it back). but
now, when prompted, i enter values into the parameter boxes but it's
doesn't discriminate, no matter what i type in it includes all of my
data. here is the query code:
SELECT
[*2005 Cleansed Paid Data YTD].[Division Name],
[*2005 Cleansed Paid Data YTD].Type,
[*2005 Cleansed Paid Data YTD].[Dest ST],
[*2005 Cleansed Paid Data YTD].[Dest Zip],
INTO
CostModelData
FROM
[*2005 Cleansed Paid Data YTD]
WHERE
((([*2005 Cleansed Paid Data YTD].[Division Name])=IIf([Division Name?]
Is Null Or [Division Name?]="all",[Division Name],[Division Name?])))
OR ((([*2005 Cleansed Paid Data YTD].Type)=IIf([Type?] Is Null Or
[Type?]="all",[Type],[Type?])))
OR ((([*2005 Cleansed Paid Data YTD].[Dest ST])=IIf([Destination
State?] Is Null Or [Destination State?]="all",[Dest ST],[Destination
State?])))
OR ((([*2005 Cleansed Paid Data YTD].[Dest Zip])=IIf([Destination Zip?]
Is Null Or Destination Zip?]="all",[Dest Zip],[Destination Zip?])));
geebee wrote:
hi,
That should not be happening, but I suppose your IIF statements are not
consistent. Post the whole SQL, and I will amend to new recommendation. We
will have a simpler SQL.
Thanks
:
i changed my WHERE statement to the one you gave me, but it still
prompts twice for each field:
DataTable.Type
Type?
DataTable.DestST
Destination State?
*DataTable.DestZip
Destination Zip?
and if i leave them all blank, it excludes all of my data. i'm so
lost...
geebee wrote:
hi,
Change your WHERE clause to:
WHERE ((([DataTable].Type)=
IIf([Type?] Is Null Or
[Type?]="all",[Type], [Type?]))
OR (([DataTable].[Dest ST])=IIf([Destination State?] Is Null Or
[Destination State?]="all",[Dest ST], [Destination State?]))
OR (([*DataTable].[Dest Zip])=IIf([Destination Zip?] Is Null Or
[Destination Zip?]="all",[Dest Zip], [Destination Zip?])));
Simply using [enter] as parameter promts in your case is different from your
parameter promts of [Type?], [Destination State?] and [Destination Zip?].
That's why it was prompting you 3 times, because you never initially used
them, and they were different from your custom parameter prompts.
geebee
:
Below is my WHERE statement. If I left in the [enter] at the end of
each part, an extra parameter box popped up every time the query ran.
However, when I take it out, rather that thinking "all" or "blank"
include everything, it sees them as including nothing. Anything you
can see wrong?
Thanks!
WHERE ((([DataTable].Type)=IIf([Type?] Is Null Or
[Type?]="all",[Type]))
And (([DataTable].[Dest ST])=IIf([Destination State?] Is Null Or
[Destination State?]="all",[Dest ST]))
And (([*DataTable].[Dest Zip])=IIf([Destination Zip?] Is Null Or
[Destination Zip?]="all",[Dest Zip])));
geebee wrote:
hi,
Yes,
You can replace "test" with your table name. And "city" with any table
column name you have. For example, you can use multiple parameters for as
many columns as you want.
For example, the following WHERE clause allows the user to enter 2
parameters for the query. One to filter the [city] column and the other to
filter the [num] column:
WHERE (((test.city)=IIf([enter] Is Null Or [enter]="all",[city],[enter])))
OR (((test.num)=IIf([enter2] Is Null Or [enter2]="all",[num],[enter2])));
Hope this helps,
geebee
:
Is "test" the name of my query, and "city" the field? Thanks so much
for replying to me.
geebee wrote:
hi,
Here is a sample query... You can adapt the syntax for your own use/query...
SELECT test.city
FROM test
WHERE (((test.city)=IIf([enter] Is Null Or [enter]="all",[city],[enter])));
Hope this helps,
geebee
:
I want to set multiple parameter queries, and allow the user to enter a
parameter for each of them or to select all if they don't want to limit
that field. What does the user type in if they want to see all in that
field? Or if they leave it blank, is there a way to code that "blank"
means "all"? Thanks so much.