Recordsaffected property problem

giedrius

Registered User.
Local time
Today, 22:47
Joined
Dec 14, 2003
Messages
80
Hello,

I have a simple update query like follows:

currentdb.execute "update products set price=price*1.1 where prodCode=12345"
X=currendb.recordsaffected

However, although some records do change, X always stays =0. Is this an A2K bug?

THanks,
giedrius
 
No, but using DAO, I've only gotten it to work on querydef objects, not the db object, like this:
Code:
Dim qdf As QueryDef
Dim X as Long
    Set qdf = CurrentDb.CreateQueryDef("", "update products set price=price*1.1 where prodCode=12345")
    qdf.Execute
    X=qdf.recordsaffected
 
Last edited:
I believe dcx693 is correct, in that the recordsaffected only works with a querydef. From help: When you use the Execute method to run an action query from a QueryDef object, the RecordsAffected property will contain the number of records deleted, updated, or inserted.
 
Thanks, it works with QueryDef. I am just wondering why is it so - both commands do perform same action (I used the same update query with QueryDef).

On the other hand, I understand, with QueryDef we loose transaction roll-back functionality available with currentdb.execute method?

giedrius
 

Users who are viewing this thread

Back
Top Bottom