G
Guest
Hi there, no matter how many things I try, I cannot delete a record if the
form is only half filled out. On my main form I have a combo box that the
user can select a company, there is then a subform that shows all of that
companies contacts. I then have another form that is opened from a button.
This form is used to add a contact, once the form is completed they can save
the record and this requeries the subfrom to show the new contact. However if
the user decides that they do not want to add a contact, I want them to be
able to exit the form without updating the records associated with that
company. I have a button - but it does not work. When I click it, it clears
the information and just puts in a blank record. The code is as follows -
'Delete the Record halfway through filling out the form and requery main form
Private Sub cmdExit_Click()
If MsgBox("Delete the current record are you sure?", _
vbYesNo + vbExclamation + vbDefaultButton2, _
"Please Confirm") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close
Forms!frmmain!sfrmImage2.Form!.Requery
End If
End Sub
Any ideas where I am going wrong?
Thanks in advance
Richard
form is only half filled out. On my main form I have a combo box that the
user can select a company, there is then a subform that shows all of that
companies contacts. I then have another form that is opened from a button.
This form is used to add a contact, once the form is completed they can save
the record and this requeries the subfrom to show the new contact. However if
the user decides that they do not want to add a contact, I want them to be
able to exit the form without updating the records associated with that
company. I have a button - but it does not work. When I click it, it clears
the information and just puts in a blank record. The code is as follows -
'Delete the Record halfway through filling out the form and requery main form
Private Sub cmdExit_Click()
If MsgBox("Delete the current record are you sure?", _
vbYesNo + vbExclamation + vbDefaultButton2, _
"Please Confirm") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close
Forms!frmmain!sfrmImage2.Form!.Requery
End If
End Sub
Any ideas where I am going wrong?
Thanks in advance
Richard