Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete curent record

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
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.

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
 
Why not simply use the BeforeInsert event procedure ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
because as the form opens default values are filled in and access saves the row.

This is a final 'sanity' check for the call rep.

Thanks,

BTW, I got it working.

Thanks

John Fuhrman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top