hello ive problem which is every time i click search(by name) n then the next thing i click save, (after save and update my data), the button previous,next,first,last doenst work, the save button function also doesnt work.
but when i click search(the name), n then the next i click the button button previous,next,first,last and it works. n after that, i click save(update my data) it also works.
pls help me check the coding
here is my coding:
'Save button
Private Sub cmdSave_Click()
On Error Resume Next
rs(0) = cmbReg.Text
rs(1) = txtDate.Text
rs(2) = cmbTitle.Text
rs(3) = txtName.Text
rs.Update
MsgBox "The record has been saved successfully.", , "ADD"
end sub
'search button
Private Sub cmdSearch_Click()
On Error Resume Next
Dim key As String, str As String
key = InputBox("Enter Name ")
Set rs = Nothing
str = "select * from Owner where Name='" & key & "'"
rs.Open str, adoconn, adOpenForwardOnly, adLockReadOnly
If rs.BOF = True Or rs.EOF = True Then
MsgBox "No Student found with that name."
Exit Sub
Else
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
Set rs = Nothing
str = "select * from Owner"
rs.Open str, adoconn, adOpenDynamic, adLockPessimistic
End If
end sub
'next button
Private Sub cmdNext_Click()
On Error Resume Next
rs.MovePrevious
If rs.BOF = True Then
MsgBox "This is the first record.", vbExclamation, "Note it..."
rs.MoveFirst
End If
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end sub
'previous button
Private Sub cmdPrevious_Click()
On Error Resume Next
rs.MoveNext
If rs.EOF = True Then
MsgBox "This is the last record.", vbExclamation, "Note it..."
rs.MoveLast
End If
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end sub
'first button
Private Sub cmdFirst_Click()
On Error Resume Next
rs.MoveFirst
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end sub
'last button
Private Sub cmdLast_Click()
On Error Resume Next
rs.MoveLast
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end sub
'delete button
Private Sub cmdDelete_Click()
On Error Resume Next
Dim ans As String, str As String
ans = MsgBox("Do you really want to delete the current record?", vbExclamation + vbYesNo, "DELETE")
If ans = vbYes Then
adoconn.Execute ("delete from Owner where Registrationnumber=" & cmbReg.Text)
MsgBox ("The record has been deleted successfully.")
Set rs = Nothing
str = "select * from Owner"
rs.Open str, adoconn, adOpenDynamic, adLockPessimistic
rs.MoveFirst
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end if
end sub
here is my form load coding :
Private Sub Form_Load()
On Error Resume Next
Dim str As String
Me.Caption = "HOUSE RENTAL MANAGEMENT SYSTEM"
Set adoconn = Nothing
adoconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sistempengurusanrumahsewa.mdb;Persist Security Info=False"
str = "select * from Owner"
rs.Open str, adoconn, adOpenDynamic, adLockPessimistic
rs.MoveFirst
cmbReg.Text = rs(0)
txtDate.Text = rs(1)
cmbTitle.Text = rs(2)
txtName.Text = rs(3)
end sub
pls help me check the coding :(