How to use Parameters in functions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want a parameter to capture the field name, and then use the /parameter as
an argument to a function. I can't figure out the syntax.

PARAMETERS fField Text;

SELECT Max(fField) as MaxValue
FROM myTable;

If I enter "Age" as the field, the query returns Age as the value in
MaxValue, where I wanted the Max of the Age field, not the string.

What's the magic voodoo syntax to pull this off.

Thanks
Jim
 
xyz_db_jim said:
I want a parameter to capture the field name, and then use the /parameter as
an argument to a function. I can't figure out the syntax.

PARAMETERS fField Text;

SELECT Max(fField) as MaxValue
FROM myTable;

If I enter "Age" as the field, the query returns Age as the value in
MaxValue, where I wanted the Max of the Age field, not the string.

What's the magic voodoo syntax to pull this off.


No voodoo, no magic, no way ;-)

Parameters represent a value that can be used in
expressions. They can not be used to change the SQL
statement.

You can however use VBA code to construct the required SQL
statement and use that in some way to get the result you
want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top