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.
 
Back
Top