Your problem is that DoCmd.RunSql can only be used with Action Statements (i.e. Insert, Append, Update). Second, you're trying to assign an Action to a variable, rather than the result of that action. Assuming that your SQL is correct, you could use a DAO recordset to get this value:
dim db...