Hi uys
My access table is empty. If I want to know whats the maximum ID value in the table in future then I use the following code:
ID is autonumber field. In order to check if there is no record in the table or when ID is null then what code can be inserted in this? Thanks
Private Sub CommandButton1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim ws1 As Worksheet
Dim r, i, Sum As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=J:\Work.mdb;"
Set rs = CreateObject("ADODB.Recordset")
strsql = "select max(id) from ZBatchTBL"
rs.Open strsql, cn
i = rs.Fields(0)
MsgBox i
rs.Close
Exit Sub
Bookmarks