G
Guest
How do I disable the "You are about to update x Row(s)" message when I'm
executing an SQL statement from code?
executing an SQL statement from code?
John Spencer said:If you are using code to execute the query you can add DoCmd.SetWarnings to
your code
DoCmd.SetWarnings False
'Execute your SQL
DoCmd.SetWarnings True
I would advise you to always turn the warning back on. And have an error
handler that does the same. Otherwise you can find yourself in the
situation where you don't get warnings when you expect to.
Better yet is to use the execute method instead of DoCmd.RunsSQL, that way
you don't need to turn warning on and off
Dim dbAny as DAO.Database, strSQL as String
Set DbAny = DbEngine(0)(0)
strSQL ="UPDATE myTable Set [Field1]=0"
DbAny.Execute StrSQL, dbFailOnError
.....
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Todd Bacon said:How do I disable the "You are about to update x Row(s)" message when I'm
executing an SQL statement from code?
Todd Bacon said:Thanks, now I get another message:
When I exit the form that contains the routine I get:
Write Conflict
This record has been changed by another user......
Any ideas?
Thanks again
John Spencer said:If you are using code to execute the query you can add DoCmd.SetWarnings to
your code
DoCmd.SetWarnings False
'Execute your SQL
DoCmd.SetWarnings True
I would advise you to always turn the warning back on. And have an error
handler that does the same. Otherwise you can find yourself in the
situation where you don't get warnings when you expect to.
Better yet is to use the execute method instead of DoCmd.RunsSQL, that way
you don't need to turn warning on and off
Dim dbAny as DAO.Database, strSQL as String
Set DbAny = DbEngine(0)(0)
strSQL ="UPDATE myTable Set [Field1]=0"
DbAny.Execute StrSQL, dbFailOnError
.....
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Todd Bacon said:How do I disable the "You are about to update x Row(s)" message when I'm
executing an SQL statement from code?
Todd said:Thanks, now I get another message:
When I exit the form that contains the routine I get:
Write Conflict
This record has been changed by another user......
Any ideas?
Thanks again
John Spencer said:If you are using code to execute the query you can add DoCmd.SetWarnings to
your code
DoCmd.SetWarnings False
'Execute your SQL
DoCmd.SetWarnings True
I would advise you to always turn the warning back on. And have an error
handler that does the same. Otherwise you can find yourself in the
situation where you don't get warnings when you expect to.
Better yet is to use the execute method instead of DoCmd.RunsSQL, that way
you don't need to turn warning on and off
Dim dbAny as DAO.Database, strSQL as String
Set DbAny = DbEngine(0)(0)
strSQL ="UPDATE myTable Set [Field1]=0"
DbAny.Execute StrSQL, dbFailOnError
.....
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Todd Bacon said:How do I disable the "You are about to update x Row(s)" message when I'm
executing an SQL statement from code?
Ofer Cohen said:It's possible that the update query is updating the same table that the form
is bounded to.
Like trying to update the same record on the same time, and that preduce the
error.
Is that the case?
If so, why do you need to run an update query if you can update the field
directly through the form?
--
Good Luck
BS"D
Todd Bacon said:Thanks, now I get another message:
When I exit the form that contains the routine I get:
Write Conflict
This record has been changed by another user......
Any ideas?
Thanks again
John Spencer said:If you are using code to execute the query you can add DoCmd.SetWarnings to
your code
DoCmd.SetWarnings False
'Execute your SQL
DoCmd.SetWarnings True
I would advise you to always turn the warning back on. And have an error
handler that does the same. Otherwise you can find yourself in the
situation where you don't get warnings when you expect to.
Better yet is to use the execute method instead of DoCmd.RunsSQL, that way
you don't need to turn warning on and off
Dim dbAny as DAO.Database, strSQL as String
Set DbAny = DbEngine(0)(0)
strSQL ="UPDATE myTable Set [Field1]=0"
DbAny.Execute StrSQL, dbFailOnError
.....
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
How do I disable the "You are about to update x Row(s)" message when I'm
executing an SQL statement from code?