Have the following code:
Dim EmKeySql As String
EmKeySql = "SELECT Max(SentEmailTbl.EmKey) AS MaxOfEmKey " & _
"FROM SentEmailTbl"
Dim EMailcon As ADODB.Connection
Set EMailcon = CurrentProject.Connection
Dim EMailRs As New ADODB.Recordset
EMailRs.ActiveConnection = EMailcon
EMailRs.CursorType = adOpenStatic
DoCmd.RunSQL EmKeySql
End Sub
I get an error in DoCmd.RunSQL that states that I must have and SQL Statement. Have tried other variations but with no success.
I just want to get the max value of a 6 digit Primary Key called EmKey. The above SQL was copied from a query in the QBE Grid, and it runs perfect in there.
The query looks fine in the immediate window, except for the error part.
Thanks
jpl
Dim EmKeySql As String
EmKeySql = "SELECT Max(SentEmailTbl.EmKey) AS MaxOfEmKey " & _
"FROM SentEmailTbl"
Dim EMailcon As ADODB.Connection
Set EMailcon = CurrentProject.Connection
Dim EMailRs As New ADODB.Recordset
EMailRs.ActiveConnection = EMailcon
EMailRs.CursorType = adOpenStatic
DoCmd.RunSQL EmKeySql
End Sub
I get an error in DoCmd.RunSQL that states that I must have and SQL Statement. Have tried other variations but with no success.
I just want to get the max value of a 6 digit Primary Key called EmKey. The above SQL was copied from a query in the QBE Grid, and it runs perfect in there.
The query looks fine in the immediate window, except for the error part.
Thanks
jpl