UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Dbfailonerror Clarifications, Access 2003    
 
   
whdyck
post Sep 13 2018, 01:52 PM
Post#1



Posts: 264
Joined: 20-July 11
From: Winnipeg, MB, Canada


I'm trying to figure out what Execute's option dbFailOnError does. In my testing, when I run Execute, it behaves the same regardless of whether I use option dbFailOnError.

I've read the online documentation regarding this option, but when I test, I find no difference in effect, whether I use this option or not.

Can someone clarify what difference I should be seeing?

Thanks.

Wayne
Go to the top of the page
 
isladogs
post Sep 13 2018, 02:05 PM
Post#2



Posts: 445
Joined: 4-June 18



CurrentDb.Execute runs with no warning messages.
If it runs successfully there is no difference whether or not you add dbFailOnError.
If the SQL fails for any reason, including dbfailonerror means you will be informed of the error.
Omitting it means you won't know if any error occurred.

--------------------
nil illigetimi carborundem est
Go to the top of the page
 
whdyck
post Sep 13 2018, 03:11 PM
Post#3



Posts: 264
Joined: 20-July 11
From: Winnipeg, MB, Canada


QUOTE
If the SQL fails for any reason, including dbfailonerror means you will be informed of the error.
Omitting it means you won't know if any error occurred.

Not sure I follow.

If I issue the following (erroneous) UPDATE statement, I get the same behaviour whether or not I include the dbFailOnError option:
CODE
CurrentDb.Execute "UPDATE tblTest SET fldTestID = 1 WHERE IDD = 0;", dbFailOnError

In both cases code execution redirects to my error-handling block (because I have the statement "On Error GoTo TestOdbcErrorsErr"). And Err.Number is reported as 3061.

Wayne
Go to the top of the page
 
Kamulegeya
post Sep 14 2018, 12:07 AM
Post#4



Posts: 1,828
Joined: 5-September 10
From: Kampala,Uganda The Pearl of Africa


To see difference, try an insert of several records in a single select insert into. With dbfailonerror,
If some of the records fail,whole batch is aborted while without it,some of the records are added.
Ronald
Go to the top of the page
 
JonSmith
post Sep 14 2018, 02:45 AM
Post#5



Posts: 3,806
Joined: 19-October 10



It might depend on the scope of the error.
For example if you try to use a field or table that doesn't exist then you will always have an error returned.

If you try to add a text value into a numeric or date field then you wont get an error unless the flag is there.

I would advocate keeping it there, the more error info you get the better most of the time.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th September 2018 - 04:15 PM