Sabtu, 18 Maret 2017

[MS_AccessPros] Form Error Handling

 

John, I added the Form_Error sub from your Contacts database to some of my forms attached to the form OnError event.  My form is not executing the sub when there is an error and I am not sure what I have to do.  Perhaps I have a misunderstanding of when a "form error occurs".

I have several forms where I have placed buttons for cmdSaveAndNew and cmdSaveAndClose.  I am intentionally adding duplicate records and my button errors are not calling your form_error sub. The duplicate records are not being saved, but there is no notification to the user.

Private Sub cmdSaveAndNew_Click()
     If (Form.Dirty) Then
        DoCmd.RunCommand acCmdSaveRecord
        Forms!frmConfigureGroupsAndSamples.SetFocus 'return to the calling form
        Forms!frmConfigureGroupsAndSamples!lstSampleGroups.Requery 'update the list box
        Me.txtSampleGroupName.SetFocus  'return to this form and set focus to the Sample Group Name again
    End If

    DoCmd.GoToRecord , "", acNewRec
    DoCmd.GoToControl "txtSampleGroupName"
End Sub


Private Sub cmdSaveAndClose_Click()
    If (Form.Dirty) Then
        DoCmd.RunCommand acCmdSaveRecord

        Forms!frmConfigureGroupsAndSamples.SetFocus 'return to the calling form
        Forms!frmConfigureGroupsAndSamples!lstSampleGroups.Requery 'update the list box
        Me.txtSampleGroupName.SetFocus  'return to this form and set focus to the Sample Group Name again
    End If

    DoCmd.Close , ""


Do I have to add your CASE statement to each of these button events?


__._,_.___

Posted by: david.pratt@outlook.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar