Re: set warnings is disabling my code



theintern <theintern@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I had a macro, with a SetWarnings command in it. it worked great. i
converted it vba. it didn't work. but, as soon as i comment out
DoCmd.SetWarnings False and click my way through it, it works great. what is
going on? i need it to not show the warnings and just continue, as it did
when it was a macro.

I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql. For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText

If you're going to use docmd.setwarnings make very sure you put the
True statement in any error handling code as well. Otherwise weird
things may happen later on especially while you are working on the
app. For example you will no longer get the "Do you wish to save your
changes" message if you close an object. This may mean that unwanted
changes, deletions or additions will be saved to your MDB.

Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
.



Relevant Pages

  • Re: VBA Error #429: ActiveX component cant create object
    ... I have a VBA procedure which sends an email. ... Late binding means you can safely remove the reference and only have ... an error when the app executes lines of code in question. ... Tony Toews, Microsoft Access MVP ...
    (microsoft.public.access.modulesdaovba)
  • Re: how to export a text file to ansys and text file to structure
    ... This newsgroup is for use of VBA in modules in the Microsoft Access database ... software product. ... An Autocad newsgroup would clearly be a better choice. ...
    (microsoft.public.access.modulesdaovba)
  • Re: table field in vba
    ... there is nothing that checks up on us, as there is in the vba editor. ... If you're doing a whole bunch of these things declaring field ... with names like FLPR-Q1 thru FLPR-Q10 ... Tony Toews, Microsoft Access MVP ...
    (comp.databases.ms-access)
  • Re: Double Click Syntax
    ... you need to do this -- newsgroups are not a substitute for Help. ... Step by Step" from Microsoft Press. ... does John Viescas et al's "Microsoft Access Inside/Out" from Microsoft ... VBA" and "Access 2007 VBA" by Hennig, Stein, et al, and recommend those. ...
    (comp.databases.ms-access)
  • Re: Adding new values to combo boxes (overriding the item not in l
    ... In the process of updating all my databases with this. ... new at databases (but work in the scientific field) but would like to get ... > Microsoft Access 2003 VBA Programmer's Reference ...
    (microsoft.public.access.modulesdaovba)