William Benson (VBACreations.Com)
vbacreations at gmail.com
Sun May 26 21:00:38 CDT 2013
I converted a command button which Access innately creates with an embedded macro, to VBA code. This was the code that was produced, and my question is, to what purpose is the MacroError (Application level) property at this point... in VBA code it appears to have no relevance, whereas the Err object itself does. For example, when trying to go to the next record when there is no next record, if this were left as a macro button, I would get the error message "You can't go to the specified record." But once I have converted the code to VBA (See below) MacroError has a value of zero, but Err.Number has a a value of 2105, which is the proper error. Anyone see any practical side to Access bothering to put code related to MacroError instead of focusing on the err object directly? Private Sub cmdNextCompany_Click() On Error GoTo cmdNextCompany_Click_Err On Error Resume Next DoCmd.GoToRecord , "", acNext If (MacroError <> 0) Then Beep MsgBox MacroError.Description, vbOKOnly, "" End If cmdNextCompany_Click_Exit: Exit Sub cmdNextCompany_Click_Err: MsgBox Error$ Resume cmdNextCompany_Click_Exit End Sub