[mso] Re: DoCmd.SetWarnings for Access 2000

  • From: "Greg Chapman" <greg@xxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Wed, 10 Dec 2003 14:17:49 -0600

This is often overlooked and of vital importance to successfully using On
Error Resume Next. Using the statement by itself is usually fine but, as
noted, errors are ignored and the code moves on. You don't have to stop
here, however, as there are plenty of times you want to know the error
before moving on, make a note of it, perform some other action, etc.

In those instances where you might expect an error you can test the value
of the Error object. Here's an example using your code:

sgSQL = "DROP TABLE tblTempDP;"
On Error Resume Next
DoCmd.RunSQL sgSQL
If Err <> 0 Then
        strErr = Now() & " " & Err.Number & _
        ", " & Err.Description & " executing " & _
        sgSQL
        LogError '(a logging routine you might consider building)
        Err.Clear
End If

With this information logged, you can finish the job and have a reference
to which parts of the process failed and records of why the failure
occurred.

Greg Chapman
http://www.mousetrax.com 
"Counting in binary is as easy as 01, 10, 11!
With thinking this clear, is coding really a good idea?"


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx 
> [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Green
> Sent: Wednesday, December 10, 2003 1:41 PM
> To: mso@xxxxxxxxxxxxx
> Subject: [mso] Re: DoCmd.SetWarnings for Access 2000
> 
> 
> Hi Anthony,
> 
> On error resume next works fine. Thankyou.
> 
> Do you think this could be a version thing perhaps? I don't find any
> reference to SetWarnings in the object browser at all.
> 
> Anyways... I have working code now so I'm relatively happy.
> 
> Thanks again
> 
> Regards
> Lisa
> 
> 
> > -----Original Message-----
> > From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx]On
> > Behalf Of Colli, Anthony G
> > Sent: 10 December 2003 16:47
> > To: mso@xxxxxxxxxxxxx
> > Subject: [mso] Re: DoCmd.SetWarnings for Access 2000
> >
> >
> >
> >
> >
> > Lisa-
> >
> > sgSQL = "DROP TABLE tblTempDP;"
> > On Error Resume Next
> > DoCmd.RunSQL sgSQL
> >
> > Will likely work. On Error Resume Next will ignore any
> > error that might
> > occur in the code. It's not a good thing to use lightly
> > because you will
> > never know when your code is generating an error.
> >
> > You should check to see if the table exists before you try
> > and drop the
> > table. You can query MySysObjects to see if the table
> > exists like this.
> >
> > SELECT MSysObjects.Name
> > FROM MSysObjects
> > WHERE (((MSysObjects.Name)="tblTempDP"));
> >
> > Then to delete the table you can use SQL or the ADOX
> > library like this.
> >
> > -------------------------------------------
> > Public Function DeleteTable()
> > Dim cat As ADOX.Catalog
> >
> > Set cat = New ADOX.Catalog
> > cat.ActiveConnection = CurrentProject.Connection
> >
> > On Error Resume Next
> > cat.Tables.Delete "tblTempDP"
> >
> > cat.Tables.Refresh
> >
> > Set cat = Nothing
> >
> > End Function
> > --------------------------------------------
> >
> > -Anthony
> >
> 
> *************************************************************
> You are receiving this mail because you subscribed to 
> mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx
> 
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> 
> To Unsubscribe from this group, send an email to 
> mso-request@xxxxxxxxxxxxx with the word "unsubscribe" 
> (without the quotes) in the subject line.
> 
> Or, visit the group's homepage and use the dropdown menu.  
> This will also allow you to change your email settings to 
> digest or vacation (no mail).
> //www.freelists.org/webpage/mso
> 
> To be able to use the files section for sharing files with 
> the group, send a request to mso-moderators@xxxxxxxxxxxxx and 
> you will be sent an invitation with instructions.  Once you 
> are a member of the files group, you can go here to 
> upload/download files:
> http://www.smartgroups.com/vault/msofiles
> *************************************************************
> 

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: