Ok here's my problem.
What i wanted to do was that if i save the value i enter on my txtbox (txtIDNo) and saves it to my database, the default value should automatically adds 1 or + 1 on it.
I set the field data type to Number and the default value to 10000. I dont want to use Autonumber because i wanted to set the default value.
If i save a new record, the default value 10000 should become 10001 for the new record.
But i dont really know why my code always get an error.
Here's the code:
Public Sub InitData()
On Error GoTo err:
If rs.State = adStateOpen Then rs.Close
rs.Open "Select * from tblEmp", cn, adOpenKeyset, adLockPessimistic
If rs.EOF = False Then
rs.MoveLast
Me.txtIDNo.Text = rs.Fields("EM_ID").Value + 1
Else
Me.txtIDNo.Text = 10000
End If
Exit Sub
err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub
Please, i really dont know what the problem is. Thanks