Hi, guys I am working on vb project, which will save client database.
I've done the coding of ADD, NEW, SAVE, EDIT button. Now, I am stuck at DELETE button. When I delete any particular client then I want my client_id (it's a column in my access database) should get updated (like if I have five clients in database and if I delete 3rd client, then the client_id should start from 1,2,3,4; not like 1,2,4,5)
I am using ADODB and Ms-access at backend, please help!!!!!
for DELETE, I've done following coding:
Private Sub cmdDelete_Click()
If rs.State = 1 Then rs.Close
admincon.Execute "delete from clientdetails where client_id=" & (lblId.Caption) & ""
MsgBox ("Record is Deleted successfully")
Clear
generateid ' It's a function i am using for generating ids. It's coding is given follow
Unload Me
frmAddClient.Show
End Sub
And for function generateid, I've done following coding:
Public Sub generateid()
Dim i As Integer
i = 1
If rs.State = 1 Then rs.Close
rs.Open "clientdetails", admincon, adOpenDynamic, adLockOptimistic, adCmdTable
Do
admincon.Execute "update clientdetails set client_id=" & i & ""
i = i + 1
rs.movenext
Loop While rs.EOF = True
End Sub