currentdb.execute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

this code does not fail but the field is not set to false either. what am I
coding incorrectly?


CurrentDb.Execute "UPDATE p_Myfile SET FN#_met = False ", dbFailOnError
 
mark r said:
this code does not fail but the field is not set to false either.
what am I coding incorrectly?


CurrentDb.Execute "UPDATE p_Myfile SET FN#_met = False ",
dbFailOnError

Try putting square brackets around the file name, which contains an
invalid character:

"UPDATE p_Myfile SET [FN#_met] = False"
 
In addition to Doug's advice, your code should have been raising an error.
In my tests, it raised error 3144, "Syntax error in UPDATE statement". If
you were not getting any error, you might want to check your error handling.
You may have an 'On Error Resume Next' somewhere in your code that you
forgot to turn off.
 
Brendan,
I am novice.......am I correct that "Resume next " would execute the next
statement after UPDATE upon the failure of the UPDATE statement? or does it
mean update the next record if the current record is not updateable?

should I code On Error Goto MSGBOX_PROCSTEP ?
 
If I go into the table and change the # sign to NUM, then I am guessing all
my queries and forms that reference the old name will not work correctly, so
I wouldn't like to go through all the work of fixing al those references. Is
my "guess" correct?
 
Mark,

"On Error Resume Next" does what your first guess said.
Note that this works to neutralize the effect of using the dbFailOnError
constant as you used it.

you could simply do:
<previous code...>
On Error Goto 0 '<-- Enables the default error handler
CurrentDB.Execute "UPDATE p_Myfile SET FN#_met = False ", dbFailOnError
On Error Resume Next ' <-- basically disables the default error handling

On a side note, this is not my preferred method of running an update query
as it does not provide any way to check whether the query actually succeeded
(it could have run cleanly and updated no records). ...but that's another
subject, if you're interested...
 
Back
Top