here's my connection code:
Public DBCon As ADODB.Connection Public Concom As ADODB.Command Public DBrs As ADODB.Recordset Public Sub DBConnect() Set DBCon = New ADODB.Connection Set Concom = New ADODB.Command Set DBrs = New ADODB.Recordset DBCon.ConnectionString = "Provider=Microsoft.jet.oledb.4.0; Data Source=" & App.Path & "\Database\HRIS.mdb" DBCon.Open Concom.ActiveConnection = DBCon End Sub Public Sub SQLcmd(SQLstatement As String) Concom.CommandText = SQLstatement Set DBrs = Concom.Execute End Sub
and here's the line that is giving me an error:
'On Error GoTo here: SQLcmd "select max(EmpID) from tblEmpPerInfo" [b]txtEmpID.Text = rs.Fields(0) + 1[/b] <-- this one here. 'Exit Sub 'here: 'If Err.Number Then <-- this is only if there is no record on the database yet. ' txtEmpID.Text = "1001" ' Exit Sub 'End If
what I'm trying to do is get the max id number in the database and add 1 on it to be use for the next record.