Jump to content

Recommended Posts

Posted

;*****************************************************************************************************************

Func _accessMaxID($adSource, $adTable)

;*****************************************************************************************************************

$max_val_id = 0

$oADO = 'ADODB.Connection'

If IsObj($oADO) Then

$oADO = ObjGet('',$oADO)

Else

$oADO = _dbOpen($adSource)

EndIf

If IsObj($oADO) = 0 Then Return SetError(1)

If Not IsObj($oADO) Then Return SetError(2, 0, 0)

$oRec = _dbOpenRecordset()

If IsObj($oRec) = 0 Then Return SetError(2)

$oRec.Open ("SELECT MAX(ID) FROM " & $adTable , $oADO, $adOpenStatic, $adLockOptimistic)

$max_val_id = $oRec.Fields(0).Value

$oADO.Close()

return $max_val_id

EndFunc

:rolleyes:

Posted

I think it would be more efficient to have a "query" function and simply supply the "select max(id)" to it rather than dedicate an entire function for that. Just my two cents.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...