Just like to say thanks to all for the responses so far. In answer to some of
those responses:
Re: David's question: Why would I ever do this? -
----------------------------------------------------------------
Where I work they have an access database launcher code written into an Excel
add-in (don't ask!) and a suite of access applications. The launcher method
is as aforementioned - to instanciate Access with CreateObject and then open
the database . Everyone's reasonably satisfied with this way of things, but
I discovered this shortcoming of not receiving critical warning messages in
data entry situations and more. I now have to find a way of getting these
warnings enabled. It would take a fair degree of effort to persuade them to
change their launcher code as it is quite a regimented environment.
Re: David's statement: I've never used anything but .Execute
once I got beyond the training-wheels stage of Access development.
----------------------------------------------------------------
I couldn't have put it better myself. The likes of RunSQL and SetWarnings are
hangers-on from macro world.
Re: salad's statement: RunSQL and Execute should produce the same results.
----------------------------------------------------------------
They should if everything all data constituents are valid and there is no
capacity for error during execution.
In any serious application, however, the user will need to be insulated from
warning messages and any execution failings will need to be properly handled
by subsequent code. So some programmers use SetWarnings False before their
RunSQL statement, but this way some data errors that occur will not trigger a
handlable error in VBA (eg. referential integrity, invalid data values). So
using the Execute method is the only real way to go.
Re: Bruce's question: Are you issuing a docmd.setwarnings true?
----------------------------------------------------------------
I mentioned I've tried setting this in my original post, but yes, I've also
tried setting this statement exactly as your code suggests, but sadly this
makes no difference (except in A97, it seems - see below).
Re: Bruce's suggestion: SetOption for "Confirm Record Changes" and "Confirm
Action Queries"
----------------------------------------------------------------
Thanks - I tried explicitly as you suggested, but no difference I'm afraid.
I also checked those settings beforehand by reading the values with the
GetOption statement - these were both set to True already.
I did a bit more testing. In Access 97, as Bruce suggested, you can issue a
SetWarnings True and this indeed brings back warning messages. Then I tried
2000, 2002 and 2003 - the warnings are switched off independently of the
SetWarnings setting. So, the issue seems specific to Access 2000 and above
(though I haven't tried it with beta 2007).
Has anyone else tried this and experienced different results to me (on
versions 2000 or above) ?
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1