RunSQL in VBA not working

racemadnss

Registered User.
Local time
Today, 14:53
Joined
May 18, 2004
Messages
58
Im trying to query my database for the Biggest number in a column then put that number into a Variable.

I have no idea how to do this, I tried this:
Code:
PrevJobNum = DoCmd.RunSQL("SELECT Max([Jobs].[JobID]) AS MaxOfJobID, [Jobs].[BusinessID] FROM Jobs GROUP BY [Jobs].[BusinessID] HAVING (((Jobs.BusinessID)=[BusinessID]));")

But all I get is the .RunSQL highlighted saying
Expected Funtion or Variable

What am I doing wrong?
 
Race,

RunSQL won't return a value.

If you have BusinessID on an open form, you can do this:

Code:
PrevJobNum = Nz(DMax("[JobID]", "Jobs", "[BusinessID] = " & Me.BusinessID), 0) + 1

Wayne
 

Users who are viewing this thread

Back
Top Bottom