gdunn59
asked on
How Can I Disable a Delete Button if The Form is Blank
I have code to delete the current record on a form. I want to be able to disable this button if the form is blank.
I have included the code for the record deletion.
How can I do this?
Thanks,
gdunn59
I have included the code for the record deletion.
How can I do this?
Thanks,
gdunn59
Private Sub cmdDelRec_Click()
On Error GoTo Err_cmdDelRec_Click
Dim rtn As String
DoCmd.SetWarnings False
rtn = MsgBox("Are you sure you want to Cancel this record?", vbYesNo)
If rtn = vbYes Then
RunCommand acCmdDeleteRecord
'DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acNewRec
Me.InquiryNum.SetFocus
Me.Requery
Else
Cancel = True
Me.InquiryNum.SetFocus
End If
DoCmd.SetWarnings True
Exit_cmdDelRec_Click:
Exit Sub
Err_cmdDelRec_Click:
Cancel = True
Resume Exit_cmdDelRec_Click
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. Thanks!
ASKER
Worked like a charm once I changed the Else Statement to True instead of False. Thanks again
You are welcome ...
mx
mx
mx