469,572 Members | 1,159 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Records Affected

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.TestField = '1'" & _
"WHERE (((TestTable.User)='Alex Lewendon'));"

db.Execute Test1
'db.RecordsAffected = Count1

MsgBox "Update Complete. " & CStr(db.RecordsAffected) & " 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 2550
1,977 1GB
Yes that is an read only property, so you cannot asigen any value.
Oct 1 '07 #2
Ok, but how can i store that value to use later??
Oct 1 '07 #3
1,977 1GB
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
469 256MB
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
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, NumberOfRecordsUpdated.

Perhaps there is an easier way than using 'Records Affected'???
Oct 1 '07 #6
1,445 Expert 1GB

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

Count1 = db.RecordsAffected

Oct 1 '07 #7
Thanks QVeen72. That worked perfectly!
Oct 1 '07 #8

Post your reply

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

Similar topics

5 posts views Thread by Rich Protzel | last post: by
12 posts views Thread by Jeff North | last post: by
2 posts views Thread by simon | last post: by
2 posts views Thread by Dave | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.