473,785 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Records Affected

94 New Member
I am performing a series of updates from a command button on an access form. I want to record the number of records affected for each update transaction.

I have simplified some code..
Private Sub cmdTest_Click()
Dim db As Database
Dim Test1, Count1 As String

Set db = CurrentDb()
Test1 = "UPDATE TestTable SET TestTable.TestF ield = '1'" & _
"WHERE (((TestTable.Us er)='Alex Lewendon'));"

db.Execute Test1
'db.RecordsAffe cted = Count1

MsgBox "Update Complete. " & CStr(db.Records Affected) & " records were updated successfully"

End Sub
As you can see i am able to show the number of affected records in a message box, but as soon as i set that value to equal a variable i receive the error message 'can't assign to read only property'.

As my actual code is performing a number of updates i want to be able to store the number of affected records for each update. Those numbers will later be written to another table..

Does anyone have any ideas??? I'm stuck.
Oct 1 '07 #1
7 2869
hariharanmca
1,977 Top Contributor
Yes that is an read only property, so you cannot asigen any value.
Oct 1 '07 #2
Lewe22
94 New Member
Ok, but how can i store that value to use later??
Oct 1 '07 #3
hariharanmca
1,977 Top Contributor
I cannot get what you mean?

Why you want to use it later. Do you mean overall updation in each record ?

If yes then use another field to keep counting.
Oct 1 '07 #4
jamesd0142
469 Contributor
from my experience in vb.net, i had to use the fill adapter, dataset etc... in order to record how many changes where made to the database.
Oct 1 '07 #5
Lewe22
94 New Member
A record of each update performed is to be stored in a seperate 'update log' table.

The update table has the following columns:

User, Update Type, DateTime, NumberOfRecords Updated.


Perhaps there is an easier way than using 'Records Affected'???
Oct 1 '07 #6
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

First declare Count1 as a Long variable and rec affected shud be on the right side:

Count1 = db.RecordsAffec ted

REgards
Veena
Oct 1 '07 #7
Lewe22
94 New Member
Thanks QVeen72. That worked perfectly!
Oct 1 '07 #8

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

Similar topics

5
11559
by: Rich Protzel | last post by:
Hello, If I run an action SP from MS Access using ADO: ... cmd.execute where the SP is something like Create... Update tbl1 set fld1 = 'something' where... how can I retrive the count of records affected like from Query
12
1883
by: Jeff North | last post by:
I'm stumped and my brains are fried!!!! I have the following data +-------+------------------------------+------------+ | resID | FLEName | VersionNbr | +-------+------------------------------+------------+ | 1 | 35_laserdatandria2104.zip | 1.0 | | 2 | 35_laserdatandria2104.zip | 1.23 | | 3 | 35_microweb1.31.zip | 1.0 | | 4 | 35_microweb1.31.zip | 1.234 |
1
2567
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected. Below is my code. here strSelectSQL value is strSelectSQL = "Select emp.Empno, emp.FirstName, emp.LastName, emp.DB, emp.DOJ,emp.Grade,emp.yearofexperience,
2
1635
by: simon | last post by:
I have datareader. I filled it with data and also if I use rdr.has rows it returns True. If I use rdr.read and scroll over it, it works. But if I wants to finds the records affected I always get -1. rdr.RecordsAffected=-1 Why?
2
4588
by: Rich | last post by:
Hello, Is there a way to capture the Records Affected count when performing a table Update on a Sql Server table using a DataAdapter? How is this done? Thanks, Rich
1
1907
by: Miriam | last post by:
Hello, I got the error "Concurrency violation: the UpdateCommand affected 0 records" while updating some records in the Windows Application. I am using VB.net in VS 2003 and the backend is Access (2000) database. My Code is just like as the following, Public Function UpdateRecord (UpdatedDataSet as DataSet, myConnstr as string, mySelectSql as string) Dim myConn as New oleDbConnection(myConnstr)
2
3237
by: Dave | last post by:
I'm in need of a little sql help. How do i get a list of ids from one table that do not have the same ids in another table? I hope that makes sense.
9
2511
by: skyloon | last post by:
I've did a program using vb6 to connect to oracle9i, i can establish the connection, the problem is when i execute the query in oracle sql*plus, it can execute successfully, but when run in vb application, the records affected return 0, it do nothing for this query, any setting need to be done? because this query insert and select to/from different database, i've created a database link for these 2 database, everything work find in oracle...
4
1871
by: Neil | last post by:
I previously posted about data shifting between records in my Access 2000 MDB with a SQL Server 7 back end, using ODBC linked tables. Every once in a while, data from one record mysteriously appears in another record. This incident happened again, this time adding a new wrinkle to the situation. There are two tables -- TableA and TableB -- which have a one-to-one relationship with each other, joined on TableA's autonumber primary key...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10090
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.