RECORDS AFFECTED

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

RECORDS AFFECTED

Post by sal21 »

How to retyruve the record affected(count) with this code:

...

Code: Select all

DBEngine.Workspaces(0).BeginTrans
        Set QRY = DB.QueryDefs("TAB_ANA")
        QRY.Parameters("[INIZIO]").Value = CDate(DATA1)
        QRY.Parameters("[FINE]").Value = CDate(DATA2)
        QRY.Parameters("[OP1]").Value = RSA.Fields("OP").Value
        QRY.Parameters("[NG1]").Value = RSA.Fields("NG").Value
        QRY.Parameters("[DESCRIZIONE1]").Value = RSA.Fields("DESCRIZIONE").Value
        QRY.Execute [b]'<<<< i think here the count records(?) or not[/b]
        DBEngine.Workspaces(0).CommitTrans
...

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RECORDS AFFECTED

Post by HansV »

QRY.Execute doesn't return any value. You can use the RecordsAffected property of the QueryDef to retrieve the number of records inserted, deleted or updated by Execute:

Code: Select all

    Dim ContaRecords As Long
    ...
    ...
        QRY.Execute
        ContaRecords = QRY.RecordsAffected
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: RECORDS AFFECTED

Post by sal21 »

HansV wrote:QRY.Execute doesn't return any value. You can use the RecordsAffected property of the QueryDef to retrieve the number of records inserted, deleted or updated by Execute:

Code: Select all

    Dim ContaRecords As Long
    ...
    ...
        QRY.Execute
        ContaRecords = QRY.RecordsAffected
AS USUAL GOOD!
Tks also for explain.