Consulting

Results 1 to 9 of 9

Thread: Editing Access Records from Excel / ADO DAO

  1. #1
    VBAX Regular
    Joined
    Jun 2004
    Location
    Vernal, UT
    Posts
    6
    Location

    Editing Access Records from Excel / ADO DAO

    I have an Excel sheet that through a form, accesses an Access database. It also has a command button that updates records with data from the sheet. In my VBA code I'm am trying to do a 'rs.edit' but the intellisense doesn't have it listed and I get a 'Method or datamember not found' error when I run the command anyway. I have checked my references and am pretty sure I have all that I need. All my other database functions (like rs.addnew) work fine. Does VBA not support editing records from a database? Or am I forgetting something?
    Last edited by interken; 06-25-2004 at 05:52 PM.

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi interken,

    Welcome to VBAX!

    Are you using DAO or ADO?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    VBAX Regular
    Joined
    Jun 2004
    Location
    Vernal, UT
    Posts
    6
    Location
    I am using DAO.
    interKen

  4. #4
    MS Excel MVP VBAX Regular Colo's Avatar
    Joined
    May 2004
    Location
    Kobe, Japan
    Posts
    23
    Location
    Hi!
    I believe the method "edit" can be used in VBA.
    What is the version of Microsoft DAO xx compatibility Library?

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    The default depends on your Office version, but if you are explicit, the DAO Edit Method should work.

    The Reference you need is Microsoft DAO 3.x Object Library, ..

    .. and the code should be something like ..

    Dim db as DAO.Database 
    Dim rs as DAO.Recordset
    ':
    ':
    Set db = DAO.Opendatabase("Drive:\Path\Name.mdb")
    Set rs = db.Openrecordset("Name"),....)
    ':
    ':
    rs.Edit
    rs!Field = something
    rs.Update
    ':
    ':
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    VBAX Regular
    Joined
    Jun 2004
    Location
    Vernal, UT
    Posts
    6
    Location
    I have the Microsoft DAO 3.6 Object Library. But I have been dimensioning my db variable as 'Database' not 'DAO.Database' would that make a difference?
    interKen

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Yes, that's critical. DAO 3.6 is Office 2K and later. In 2K the default changed from DAO to ADO.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    VBAX Regular
    Joined
    Jun 2004
    Location
    Vernal, UT
    Posts
    6
    Location
    Solved! The DAO.Database & DAO.Recordset was the answer. Thanks guys for all your help.
    interKen

  9. #9
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Cool.

    Marked Solved.
    ~Anne Troy

Posting Permissions

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