get the max id from the query and ado connection
Code:
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As New ADODB.Command
Dim sSql As String
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
sSql = "SELECT Max(tNames.ClientID) AS MaxOfClientID FROM tNames;"
With cmd
.CommandText = sSql 'Name of the stored procedure
.CommandType = adCmdText
.ActiveConnection = conn.ConnectionString
End With
Set rst = cmd.Execute
'fill in the value here
txtBox = rst.Fields("MaxOfClientID").Value
conn.Close
Set rst = Nothing
Set conn = Nothing