473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

docmd.RunSQL Update records in table how can I get rid of the "You are about to update" message

RC
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?
Nov 13 '05 #1
8 11192
You can turn off SetWarnings, and turn it on again later.

Alternatively, Execute your action query like this:
dbEngine(0)(0).Execute "UPDATE ...

That gives you no warning. If you want to stop if there is an error, use:
dbEngine(0)(0).Execute "UPDATE ... ", dbFailOnError
And if you want to be able to roll back the entire thing if there is an
error, use a transaction. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?

Nov 13 '05 #2
RC
Thank you very much Mr. Brown! Not only did you answer my specific
question but you taught me about Transactions which I didn't know
anything about. I will set up the Update so that if there is an
error, the user can roll-back the changes and try again or
proceed/accept the changes with the error and check the database to
make sure the changes are OK.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
You can turn off SetWarnings, and turn it on again later.

Alternatively, Execute your action query like this:
dbEngine(0)(0).Execute "UPDATE ...

That gives you no warning. If you want to stop if there is an error, use:
dbEngine(0)(0).Execute "UPDATE ... ", dbFailOnError
And if you want to be able to roll back the entire thing if there is an
error, use a transaction. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?

Nov 13 '05 #3
RC
I could not get the dbEngine(0)(0) thing to work.

The following code works:
Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DoCmd.RunSQL ("UPDATE Products " & _
"SET Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] " & _
"WHERE
(([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]));")
End Sub

But when I try using dbEngine like this:

Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DBEngine(0)(0).Execute ("UPDATE Products SET
Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] WHERE
([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]);"),
dbFailOnError
End Sub

I get the error message: "Too few parameters, expected two." I tried
various changes but I could not get it to work.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
You can turn off SetWarnings, and turn it on again later.

Alternatively, Execute your action query like this:
dbEngine(0)(0).Execute "UPDATE ...

That gives you no warning. If you want to stop if there is an error, use:
dbEngine(0)(0).Execute "UPDATE ... ", dbFailOnError
And if you want to be able to roll back the entire thing if there is an
error, use a transaction. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?

Nov 13 '05 #4
Change your SQL to read as follows:

DBEngine(0)(0).Execute ("UPDATE Products SET
Products.ContainerNumberProductsTable =" &
[Forms]![ContainerAssociationForm]![GETContainerNumber] & " WHERE
[Products.PalletNumberProductsTable]=" &
[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox],dbFai
lOnError

Since the queries retrieve parameters from forms, you'll need to make those
values part of the SQL string (well, you don't have to, but it's much easier
to do it this way). In the above, I'm assuming both fields are numeric data
types. If they aren't, you'll need to add text delimiters around the
parameters.

--
Shane Suebsahakarn
----
Head of IT
PAN Telecom
Tel: +44 (0) 870 757 7001

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
I could not get the dbEngine(0)(0) thing to work.

The following code works:
Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DoCmd.RunSQL ("UPDATE Products " & _
"SET Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] " & _
"WHERE
(([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![P
alletNumberContainerFormComboBox]));") End Sub

But when I try using dbEngine like this:

Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DBEngine(0)(0).Execute ("UPDATE Products SET
Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] WHERE
([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![Pa
lletNumberContainerFormComboBox]);"), dbFailOnError
End Sub

I get the error message: "Too few parameters, expected two." I tried
various changes but I could not get it to work.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message

news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
You can turn off SetWarnings, and turn it on again later.

Alternatively, Execute your action query like this:
dbEngine(0)(0).Execute "UPDATE ...

That gives you no warning. If you want to stop if there is an error, use: dbEngine(0)(0).Execute "UPDATE ... ", dbFailOnError
And if you want to be able to roll back the entire thing if there is an
error, use a transaction. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?

Nov 13 '05 #5
RC wrote:
I could not get the dbEngine(0)(0) thing to work.

The following code works:
Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DoCmd.RunSQL ("UPDATE Products " & _
"SET Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] " & _
"WHERE
(([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]));")
End Sub

But when I try using dbEngine like this:

Private Sub PalletNumberContainerFormComboBox_AfterUpdate()
DBEngine(0)(0).Execute ("UPDATE Products SET
Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] WHERE
([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]);"),
dbFailOnError
End Sub

I get the error message: "Too few parameters, expected two." I tried
various changes but I could not get it to work.


You need to parse the form objects yourself, DAO knows nothing of them

DBEngine(0)(0).Execute "UPDATE Products SET " & _
"Products.ContainerNumberProductsTable = " & _
[Forms]![ContainerAssociationForm]![GETContainerNumber] & _
"WHERE [Products.PalletNumberProductsTable]=" & _

[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox],
dbFailOnError
--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #6
"Trevor Best" wrote:

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\


Trevor, you should be torched for that sig! :-)

The way Windows interprets the backslashes is brilliant. Lights on, but
nobody's home.
Nov 13 '05 #7
RC
Thank you very much, all of you and Thank you to Allen Browne for
teaching me about Transactions from your website at:
http://members.iinet.net.au/~allenbrowne/ser-37.html

I didn't know anything about Transactions and now I am going to write
that into any applicable areas to prevent any database catastrophes.

I tried various adjustments to the code samples provided and kept
getting syntax errors. The code below (with different table and form
names) works for me.

DBEngine(0)(0).Execute "UPDATE Table1 SET " &
"[Table1]![ContainerNumber] = " & [Forms]![Form1]![Text3] & " WHERE
[Table1]![PalletNumber]= " & [Forms]![Form1]![GetPalletNumberBox],
dbFailOnError

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
"Trevor Best" wrote:

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\


Trevor, you should be torched for that sig! :-)

The way Windows interprets the backslashes is brilliant. Lights on, but
nobody's home.

Nov 13 '05 #8
Try something like...

DoCmd.SetWarnings = False
DoCmd.RunSQL ("SQLSTRING")
DoCmd.SetWarnings = True

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
In my Access 2002 form, I have a combo box and on the AfterUpdate
event I use

DoCmd.RunSQL ("UPDATE ....
to update records in a table. When it starts to run I get a message
"You are about to update 3 row(s)."
Is there a way to prevent the message from popping up?

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
1
by: Daniel Chou | last post by:
Hello, I have two questions about "not logged initially": 1. Before using "alter table tbname activate not logged initially", should the table be created with "not logged initially"? 2....
4
by: Rotsj | last post by:
Hi, i try to execute an update query from within a form, but i get the message: run time error '3144'. Syntax error on the update statement when i try something like this: DoCmd.RunSQL...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
3
by: Rob Meade | last post by:
Hi all, Ok - probably really obvious and something I'm clearly missing...but ... I have a form with 3 areas for text to be entered, the form has some validation controls, upon it being...
4
by: JDC | last post by:
Hi all, I'm using ObjectDataSource to select & update records. I have a "RecordDetails" class which encapsulates the row I want to update, and so it contains the fields I want to update and also...
5
by: Lennart | last post by:
I really like the construction: select * from new table (update ....) X but I noticed that it cant be used as: insert into T select * from new table (update ....) X because of:
3
by: spaghetti | last post by:
Hi forum I'm totally new to php and mySQL so please excuse my ignorance. I've been trying to research this but because I'm not totally sure what I'm searching for I haven't yet found a solution. ...
3
by: 01423481d | last post by:
Hi All I am facing a very strange "problem" on the captioned issue, I hope I can explain it clearly. Actually I am developing an interface (using VB.net) which read records from a file and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.