473,387 Members | 3,033 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,387 software developers and data experts.

Best way of updating a table, based on the results of a query

Hi All,

I have a select query which is based on tblOne and tblTwo. The query selects
some of the records in tblOne and tblTwo, based on a Where condition.
What I need to do is to change the value in Field9 in tblOne for all the
records found by the query.
I am not sure if I should use an update query or if I use some vba code.
In case I will have to use an update query, is there a way to disable the
warning prompts of it? (Or any warnings given by a query for that matter).
If I open an action query from VBA, it raises some warnings, and I don't
need the warnings sometimes.

Regards,
Nicolae


Nov 13 '05 #1
3 1805
Nicolae,
Given a choice, I favor doing things with SQL whenever possible. So, I'd go
with the UPDATE statement. You can suppress & manage warnings, etc., by
running the update statement inside a function in VB, giving you the best of
both techniques.

"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net...
Hi All,

I have a select query which is based on tblOne and tblTwo. The query selects some of the records in tblOne and tblTwo, based on a Where condition.
What I need to do is to change the value in Field9 in tblOne for all the
records found by the query.
I am not sure if I should use an update query or if I use some vba code.
In case I will have to use an update query, is there a way to disable the
warning prompts of it? (Or any warnings given by a query for that matter).
If I open an action query from VBA, it raises some warnings, and I don't
need the warnings sometimes.

Regards,
Nicolae

Nov 13 '05 #2
Hi Alan,

Thank you for your oppinion. The guy who supervises me doesn't want me to
use sql query expressions in my code. He wants to be able to run a query
outside the code and to check the results. I must admit, it is easier to
debug the application this way instead of embeding the sql statements in the
vba code... And I would expect there is a way of running an existing query
from VBA. After this message I posted some other piece of code, which is
able to execute an external update query, but there is an error in the code.
Once I figure out what the problem is, there won't be necessary to embed
queries in the code (I think).

Regards,
Nicolae
"Alan Webb" <kn*****@hotmail.com> wrote in message
news:sV******************@news.uswest.net...
Nicolae,
Given a choice, I favor doing things with SQL whenever possible. So, I'd go with the UPDATE statement. You can suppress & manage warnings, etc., by
running the update statement inside a function in VB, giving you the best of both techniques.

Nov 13 '05 #3
Nicolae,
I don't supposed telling him to relax would do any good. You can use the
msgbox command to display the embedded SQL in a message box. You can also
set the caption property of a label control to your embedded SQL. But your
boss is a bit clueless because an update statement modifies the data and is
not meant to be a means of checking the results. If he needs validation
before vetting the changes you should build him views using SELECT
statements that show him what the changes will look like after the update
statement is run. Update Queries based on the Jet db engine (a bit of an
oxymoron, but . . .) allow you to view the query in datasheet view and
that's probably what your boss is used to working with. Work out a process
flow with him that allows him to validate the proposed changes and then
running the embedded SQL to finalize them. That way you can write in
whatever way makes the most sense and your boss can have the verification he
or she needs.

"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40******@duster.adelaide.on.net...
Hi Alan,

Thank you for your oppinion. The guy who supervises me doesn't want me to
use sql query expressions in my code. He wants to be able to run a query
outside the code and to check the results. I must admit, it is easier to
debug the application this way instead of embeding the sql statements in the vba code... And I would expect there is a way of running an existing query
from VBA. After this message I posted some other piece of code, which is
able to execute an external update query, but there is an error in the code. Once I figure out what the problem is, there won't be necessary to embed
queries in the code (I think).

Regards,
Nicolae
"Alan Webb" <kn*****@hotmail.com> wrote in message
news:sV******************@news.uswest.net...
Nicolae,
Given a choice, I favor doing things with SQL whenever possible. So,
I'd go
with the UPDATE statement. You can suppress & manage warnings, etc., by
running the update statement inside a function in VB, giving you the
best of
both techniques.


Nov 13 '05 #4

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

Similar topics

7
by: sql-db2-dba | last post by:
Does DB2 just fudge it when it is an empty table? Is there a "formula" for average row size when you have variable length records. Or you really have to know what your application is packing into...
1
by: Foxster | last post by:
i have created a query that gives the sum of a table "results".... i created the fields sums1, sums2....from that table results and i have put the fields from another talbe (coupled with a field...
1
by: Alex Hemingway | last post by:
I have a table Products consisting of the following fields :- ProductID, ProductName, PriceLevel, UnitPrice and a query which returns all products with a specific PriceLevel. What I would like...
7
by: Foxster | last post by:
in access i have two tables (tblplayer, tblpoints) in tblplayer i have field totalpoint (number) in tlbpoints i have field pointgame (number) the two files are related via idplayer now i made a...
1
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
9
by: hrreece | last post by:
I have an Access 2002 database that has a form that can be used to review individual records. At the bottom of the form are buttons that are linked to functions that allow the user to "Find a record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.