Darryl Collins
darryl at whittleconsulting.com.au
Sun May 26 22:18:42 CDT 2013
In my experience this sort of thing is typical of auto generated VBA scripted by MSoft. Perhaps they used to farm this sort of thing out to first year interns(?) - I mean, it must be a fairly tedious thing to set up. Dunno. But I nearly always find I can strip down their auto-code by about 90%. Indeed I would recommend it as it is often full of meaningless bloat that just takes up space and fogs clarity. Cheers Darryl -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Benson Sent: Monday, 27 May 2013 12:36 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] MacroError - VBA?? Gr8. Sigh. Thanks. On May 26, 2013 10:24 PM, "Stuart McLachlan" <stuart at lexacorp.com.pg> wrote: > Looks to me like a braiin-dead automated Macro to VBA conversion > process that doesn't deal with error trapping properly. > > To answer your first question - it serves no purpose. > > > On 26 May 2013 at 22:00, William Benson (VBACreations. wrote: > > > 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 > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com