Capturing Max Value in Code

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

Hi All,

I am trying to get the max value in a field of a table
using the following statement.

DoCmd.RunSQL "SELECT Max(ABC1MASTER![CLAIM7]) AS
MaxOfCLAIM7 FROM ABC1MASTER;"

The code produces the error:

A RunSQL action requires an argument consisting of an SQL
statement.

When run from the immediate window I get:

Compile error: Argument not optional

The only other argument is one for usetransaction, which
does not change the result.

Apparently the code does not recognize the SQL so I tried
parenthesis and separators but I am missing something

Once this is running, do I need to dimension MaxOfClaim7
to use the value since there is an option explicit line?

Thanks,

al
 
The only thing I can see that looks odd is the Bang here:
ABC1MASTER![CLAIM7])
it should be a dot
ABC1MASTER.[CLAIM7])
or leave the table name off completely
Max([CLAIM7]) AS MaxOfCLAIM7
 
Back
Top