que tal, espero que te sirva este ejemplo:
Código:
Public Function Retorna_Ultimo(ByVal tabla As String, ByVal pktabla As String) As Integer
Dim Ad As New accesodatos.Operaciones(Command)
Dim Codigo As Integer
Command.CommandText = "Select Max(" & pktabla & ") From " & tabla
Codigo = Command.ExecuteScalar
Return Codigo
End Function
Suerte