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.

Number of records changed by an action query

2
Hey all,

As part of an access application, I am importing data from an XML file into a table, then using an update query to process the imported data into various other tables in the database where it belongs. I have the queries running fine, but I cannot for the life of me find out how to, from a VB code perspective, get the number of records that will be updated (or were updated) by a query.

I'm trying to make something similar to the default Access warning message box that says "You are about to update XX record(s)", except a custom message that more closely reflects what the user is actually trying to do when the query is executed.

The closest I've got it using an SQL Count() function in a SELECT query based on the update query I have just run, but it seems a bit of a long way of going about it.

Any help appreciated.
Nov 3 '06 #1
8 4581
pks00
280 Expert 100+
Run an action query using currentdb.execute then find out number of records modified

eg

Dim db As DAO.Database


Set db = CurrentDb
db.Execute "UPDATE mytable SET myfield=22"

msgbox db.RecordsAffected


If it complains about dao, u need to add it as a reference, in vba window go to tools/references then check microsoft dao 3.6 object library
Nov 3 '06 #2
NeoPa
32,556 Expert Mod 16PB
I love learning new things on here.
Thanks pks00 - this should prove uber-useful.
Nov 3 '06 #3
PEB
1,418 Expert 1GB
Yeah,

You're a great girl pks00 :)

Never used a staff like this one...

msgbox db.RecordsAffected

Is needed to use Begintrans and CommitTrans methods with this methode?

My God you're pleinty with surprises..

;)


Run an action query using currentdb.execute then find out number of records modified

eg

Dim db As DAO.Database


Set db = CurrentDb
db.Execute "UPDATE mytable SET myfield=22"

msgbox db.RecordsAffected


If it complains about dao, u need to add it as a reference, in vba window go to tools/references then check microsoft dao 3.6 object library
Nov 4 '06 #4
thefj
2
You have no idea how much hair you have prevented me losing! I can't believe such a simple and useful reporting method is so difficult to find.

Thanks :)
Nov 5 '06 #5
NeoPa
32,556 Expert Mod 16PB
I'm with you on that!
Nov 6 '06 #6
pks00
280 Expert 100+
Howdo, Peb

and thanks all:)

To tell you the truth, I have no idea whether it works with BeginTrans/CommitTrans. Ive never used these methods with DAO before#
Sorry



Yeah,

You're a great girl pks00 :)

Never used a staff like this one...

msgbox db.RecordsAffected

Is needed to use Begintrans and CommitTrans methods with this methode?

My God you're pleinty with surprises..

;)
Nov 10 '06 #7
NeoPa
32,556 Expert Mod 16PB
It is probably possible to use this with begin and end trans, but I'm fairly sure they're not required.
Nov 10 '06 #8
PEB
1,418 Expert 1GB
For me it's curious where Access keeps the information for the affected records if this isn't in the buffer where it keeps info for the transactions...

It's thing that should be checked!
Nov 18 '06 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ian Davies | last post by:
Hello In a php file I have a drop down list with index numbers in whos default value is feed into an sql query that filters records from my database and displays them in an html table. Trouble...
1
by: Steve Lilley | last post by:
Hello All Can you please help me with a problem, I'm only looking for a starting point as I am a long way from even knowing exactly what I want to do. Here's the basics anyway, any help much...
3
by: Peter | last post by:
Dear all, Would you tell me how to solve the following two problems in an access file upon preparing report form: a) I have written an IIf function for a string field at the beginning of...
6
by: Sven Pran | last post by:
Probably the answer is there just in front of me only awaiting me to discover it, but: 1: I want to build a query that returns all records in one table for which there is no successful "join"...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
8
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
19
by: eric.nave | last post by:
this is a slight change to a fequently asked question around here. I have a table which contains a "sortorder" column where a user can specify some arbitrary order for records to be displayed in. ...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
5
by: slickdock | last post by:
I need to break my query into 3 groups: First 60 records (records 1-60) Next 60 records (records 61-121) Next 60 records (records 122-182) Of course I could use top values 60 for the first...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.