View Full Version : Query with parameter to select certain fields


helios_lie
01-12-2008, 11:19 PM
Hi, I need help in creating a parameterized query.

I need to show only certain fields depending on the value of the parameters.
For example, I have a table with fields: ID, Name, Phone Number, Address, DOB.
The parameter can only be value of A, B or C.
If the user input A as the parameter in the query, only field ID, and Name will be shown
If the user input B as the parameter in the query, field ID, Name and Phone Number will be shown.
etc.

Is there any way to do this, rather than to separate the query into 3 queries for each of the parameters? Thank you.

ajetrumpet
01-13-2008, 12:28 AM
Is there any way to do this, rather than to separate the query into 3 queries for each of the parameters? Thank you.Probably not within the query itself. I would create a query with every field that is possible in the result set. Then, I would base a form off of that query, because forms are easier to manipulate (in terms of "display") than queries are. Maybe you could use the .visible property of form controls to hide/show the fields you wanted (based on the user-entered parameter)??