GRAHAM
May 16th, 2000, 05:02 AM
This is my first shot at a db application, and I have not been given any tuition on error handling at Uni. My app. works i.e I can add, search for records, but the delete function cases a problem. When I close the app. and open the db again, the record has been deleted, so the code is working in some fashion.
The problem happens when I select Yes in the MsgBox... I have to select Yes twice before the Msgbox closes, then all other functions cease to work.
Could someone point out the problem in the code, and show me where to insert some error handling. The code I am using is as follows
Private Sub cmdDelete_Click()
Set rs = db.OpenRecordset("SELECT wagedetails.name, wagedetails.grade, wagedetails.department, wagedetails.taxallowance From wagedetails WHERE wagedetails.name = " + Chr$(34) + txtName.Text + Chr$(34) + ";")
MsgBox "This action will permanently delete the record. Do you wish to continue?", vbYesNo, "Delete Record"
If MsgBox("This action will permanently delete the record. Do you wish to continue?", vbYesNo, "Delete Record") = vbYes Then
With rs
.Delete
.MovePrevious
.Close
End With
Else
rs.MovePrevious
End If
End Sub
Any help would be very much appreciated
GRAHAM :)
[Edited by GRAHAM on 05-16-2000 at 07:59 PM]
The problem happens when I select Yes in the MsgBox... I have to select Yes twice before the Msgbox closes, then all other functions cease to work.
Could someone point out the problem in the code, and show me where to insert some error handling. The code I am using is as follows
Private Sub cmdDelete_Click()
Set rs = db.OpenRecordset("SELECT wagedetails.name, wagedetails.grade, wagedetails.department, wagedetails.taxallowance From wagedetails WHERE wagedetails.name = " + Chr$(34) + txtName.Text + Chr$(34) + ";")
MsgBox "This action will permanently delete the record. Do you wish to continue?", vbYesNo, "Delete Record"
If MsgBox("This action will permanently delete the record. Do you wish to continue?", vbYesNo, "Delete Record") = vbYes Then
With rs
.Delete
.MovePrevious
.Close
End With
Else
rs.MovePrevious
End If
End Sub
Any help would be very much appreciated
GRAHAM :)
[Edited by GRAHAM on 05-16-2000 at 07:59 PM]