I have a form that I need to have check three controls for data when the form is closed and if any of them are not filled in prompt the user for what they want to do.
This is because Access is adding rows to the DB that are incomplete on the main input form.
Here is what i have so far. It does everything BUT remove the record.
Thanks
John Fuhrman
This is because Access is adding rows to the DB that are incomplete on the main input form.
Here is what i have so far. It does everything BUT remove the record.
Code:
Private Sub Form_Unload(Cancel As Integer)
If IsNull(Me.[Contact Name].Value) Or IsNull(Me.Afile_Number.Value) Or IsNull(Me.Memo.Value) Then
Dim strResponse, strResponse2
strResponse = MsgBox("Record is incomplete." & vbCrLf & _
"Do you wish to SAVE the record?", vbQuestion + vbYesNoCancel)
Select Case strResponse
Case vbYes
DoCmd.RunCommand acCmdSaveRecord
Case vbNo
DoCmd.RunCommand acCmdUndo
strResponse2 = MsgBox("Record is incomplete." & vbCrLf & _
"DELETE this record?", vbQuestion + vbYesNo)
Select Case strResponse
Case vbYes
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
Case vbNo
'Do Nothing
End Select
Case vbCancel
Cancel = True
End Select
End If
End Sub
Thanks
John Fuhrman