SQL based on recordset

hbrems

has no clue...
Local time
Today, 04:06
Joined
Nov 2, 2006
Messages
181
Hi,

I have created a recordset based on an SQL statement:

Code:
sql = "SELECT * FROM tblusers"
rstbe.Open sql, cnnbe, adOpenKeyset, adLockOptimistic

Is it possible to get the value of the record with the highest id number (flduserid), based on this recordset, but without altering the SQL statement?

Kind regards,
Hans B.
 
Not easily (though it's not hard). You'll have to loop the recordset, and since you haven't specified a sort order, you'll need a variable to put the highest id into, and compare each record to that. Why don't you want to change the SQL?
 
You could just run another query:
MaxValue = CurrentProject.Connection.Execute("SELECT MAX(flduserid) FROM tblusers").Fields(0).Value
 

Users who are viewing this thread

Back
Top Bottom