Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jun 2002
    Location
    London, Gtr London, England
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    capture number of rows to be updated (Using Acc2000, with DAO)

    Pls help.

    how can I capture how many rows I am updating within my UPDATE code.

    "You are about to update 0 rows" then
    do this
    else
    do that

    (Nice to work with warnings off also!)

    Many thanks,

    J

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: capture number of rows to be updated (Using Acc2000, with DAO)

    Use a dcount function with the same where clause as in the update query.
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: capture number of rows to be updated (Using Acc2000, with DAO)

    I think you'd have to open a recordset based on the equivalent SELECT or SELECT DISTINCT code, then get the RecordCount of the recordset. The count will not be accurate unless you move to the end of the recordset first, but it will tell you if there are records to be updated or not.

  4. #4
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: capture number of rows to be updated (Using Acc2000, with DAO)

    Use a DAO database object

    dim db as DAO.Database
    set db = currentdb

    Then use the EXECUTE method of the database object to do the update

    db.execute("UPDATE ... ")

    Then call the RECORDSAFFECTED property of the database object

    msgbox("Updated " & db.recordsaffected & " records.")

    This should work.

    You could encapsulate the operation in a transaction maybe to rollback if need be?

  5. #5
    Star Lounger
    Join Date
    Jun 2002
    Location
    London, Gtr London, England
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: capture number of rows to be updated (Using Acc2000, with DAO)

    thx
    got it!

  6. #6
    Star Lounger
    Join Date
    Jun 2002
    Location
    London, Gtr London, England
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: capture number of rows to be updated (Using Acc2000, with DAO)

    thx to all
    got it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •