He estado viendo esta funcion que puso Ugoldman en la biblioteca:
<%
Function GetMyMaxId(table, field)
Set rsGetMyMaxId = Server.CreateObject("ADODB.Recordset")
strSQLGetMyMaxId = "SELECT MAX(" & field & ") AS myMax FROM " & table
rsGetMyMaxId.Open strSQLGetMyMaxId, ObjConn, 3, 3
fnctMyMaxId = rsGetMyMaxId("myMax")
If IsNull(fnctMyMaxId) Then
fnctMyMaxId = 0
End If
rsGetMyMaxId.Close
Set rsGetMyMaxId = Nothing
GetMyMaxId = fnctMyMaxId
End Function
%>
Llamada a la función
Cita:
MaxID = GetMyMaxId("tabla", "campo")
¿Como podria modificar la funcion para que me proporcionase en lugar del valormaximo que toma el campo, el autonumerico(clave principal) de la tabla?
GetMyMaxId(
"autonumerico" ,"tabla", "campo")