Jumat, 07 April 2017

[MS_AccessPros] Inconsistent Error 424 - Object Required

 

I have an unbound form with three cascading list boxes and each list box has an Add and a Delete command button.  The Add button on the third list box is inconsistently throwing an error 424 Object Required.  I put in a break and so far when I step through I have been unable to get it to error.

I added John's error management and error logging and verified that the form that is called for the record addition is not the cause of the error.  The error is being logged as an error from the ADD command button on the unbound form.  The error apparently occurs after the form is closed and processing returns to the code in the  AddNew list button click event.  This is verified by the fact that the new record is created in spite of throwing the error. The only step performed after closing the new record form is a requery of the list box. 

My code is below if anyone can possibly see what I am doing incorrectly.

I also have a general question about error management in this scenario where I have a command button calling a form.  I now have John's Form_Error and SaveIt() function error management on all of my ADD forms.  What kind of error management should I have on the command button procedures which call the forms?  Obviously Error 424 is possible.  However, I don't want to code in management of a bunch of errors which cannot happen in this scenario.  Right now most all of these procedures merely have:
   MsgBox err.description
   Resume Done
Based on this experience, this certainly is not adequate.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Private Sub cmdNewSamplePoint_Click()
    Dim lngErr As Long, strErr As String
    On Error GoTo ErrHandler
   
    If Me.lstEquipment.ItemsSelected.Count > 0 Then
        DoCmd.OpenForm "frmSamplePoint", acNormal, , , acFormAdd, acDialog, _
        lstEquipment.Value
       
        Me.lstSamplePoints.Requery
    Else
        MsgBox "You must select Equipment to which the new Sample Point is to be added." _
        , vbInformation, gstrAppTitle
    End If
Done:
    Exit Sub
ErrHandler:
    Select Case Err 'identify the error
        Case errCancel, errCancel2, errPropNotFound ' Cancel - ignore; Variables are declared in modGlobals
            Resume Done
        Case errDuplicate  ' Duplicate row - custom error message
            MsgBox "This record already exists.  Enter a new record or click Cancel.", vbCritical + vbRetryCancel, gstrAppTitle
            'Me.txtSomeControlName.SetFocus
        Case errInvalid, errValidation, errInputMask, errGeneral, errTableValidate
            ' Validation rule - custom error and log
            MsgBox "You have failed to enter a required value or have entered an invalid value. ", _
                vbCritical + vbRetryCancel, gstrAppTitle
            ErrorLog Me.Name & "_Save", Err, Error
        Case Else
            ' Undefined error - log to table ErrTable and let error display; ErrorLog is a Public Sub in modUtility
            ' Save the error code values because ErrorLog may get additional errors
            lngErr = Err
            strErr = Error
            ErrorLog Me.Name & "_cmdNewSamplePoint", lngErr, strErr
            MsgBox "Error attempting new Sample Point: " & lngErr & " " & strErr & Chr$(13) & Chr$(10) & "Try again or click Cancel to close without saving.", vbRetryCancel, gstrAppTitle
    End Select
    Resume Done
End Sub

 

__._,_.___

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