So I Put in what you wrote down and changed the f1-6 to the column names.
But when I run the query it asks for the column i want to search by then asks
for the parameters of that column and each subsequent column. Is there a way
to change this so it only asks for the parameters of the column I choose?
Here is what I currently have down:
SELECT * FROM [Central Records Storage]
WHERE SWITCH( [Which column]='Project Name', Project_Name,
[Which column]='Project ID', Project_ID,
[Which column]='Address', Address,
[Which column]='Legal Description', Legal_Description,
[Which column]='Cross Reference', Cross_Reference,
true, Location) = [Which
value you scan for]
So for example I searched by address and then it asked for the parameters of
address, Legal, Cross Reference, and Location. I have also created a
Parameter query for each column that works fine. Would it be easier to
create a query that runs one of the parameter queries depending on which
column is selected? If so could you show me how that would be set up.
Michel Walsh said:
Hi,
If just one column will ever be selected, but you don't know which one, you
can try something like:
SELECT * FROM myTable
WHERE SWITCH( [Which column]='f1', f1,
[Which column]='f2', f2,
[Which column]='f3', f3,
[Which column]='f4', f4,
[Which column]='f5', f5,
true, f6) = [Which value
you scan for]
I assumed the column names are f1, f2, f3, f4, f5 and f6. The query asks
for two parameters, the field name to look into (or any other similar info,
just rewrite the various tests), and the value to scan.
That could be TERRIBLY SLOW on large table, since indexes would not be put
to contribution.
Hoping it may help,
Vanderghast, Access MVP
Fupp83 said:
I have a table that has six columns: Project Name, Project ID, Address,
Legal
Description, Cross-Reference, and Box Number. I want to create a query
where
a person can search for records using any of these fields. I know i can
create a parameter query for each field, but is there a way I can combine
all
those parameter queries so a person can choose one parameter then be
prompted
with the search question/box?