Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Basic DAO Question (A2K SR1)

    I am trying to update a field in a table that contains 1 record. When I try to compile the following code I get the error message: Method or data member not found with .Edit highlighted.

    Public Const DatabaseName As String = "CELPHIDELPHI.MDB"
    Public Const CashDBName As String = "CELPHICash.MDE"
    Public Const NewCashDBName As String = "CELPHINewCash.MDE"

    Public Function TestLastModDate()

    Dim dbDELPHI As Database, rcdBackEnd As Recordset
    Dim dbCash As Database, rcdFrontEnd As Recordset
    Dim FrontEndModDate As Date, BackEndModDate As Date

    Set dbDELPHI = OpenDatabase(DatabaseName)
    Set dbCash = OpenDatabase(CashDBName)
    Set rcdFrontEnd = dbCash.OpenRecordset("LastModified", dbOpenDynaset)
    Set rcdBackEnd = dbDELPHI.OpenRecordset("UpdateHistory", dbOpenDynaset)

    rcdFrontEnd.MoveFirst
    rcdBackEnd.MoveFirst

    FrontEndModDate = rcdFrontEnd!LastModified
    BackEndModDate = rcdBackEnd!LastCashMod

    If FrontEndModDate > BackEndModDate Then
    With rcdBackEnd
    .Edit
    .LastCashMod = FrontEndModDate
    .Update
    End With <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

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

    Re: Basic DAO Question (A2K SR1)

    Did you have set the reference to Microsoft DAO 3.6 in the Menu Tools, References in VBE ?
    Change the code to :
    Public Const DatabaseName As String = "CELPHIDELPHI.MDB"
    Public Const CashDBName As String = "CELPHICash.MDE"
    Public Const NewCashDBName As String = "CELPHINewCash.MDE"

    Public Function TestLastModDate()

    Dim dbDELPHI As DAO.Database, rcdBackEnd As DAO.Recordset
    Dim dbCash As DAO.Database, rcdFrontEnd As DAO.Recordset
    Dim FrontEndModDate As Date, BackEndModDate As Date
    Francois

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: Basic DAO Question (A2K SR1)

    Thanks. I did have DAO 3.6 in the reference list but the DAO prefix worked. Strange I have never used that before and I have been able to read and write DAO tables.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Basic DAO Question (A2K SR1)

    The problem is that both DAO and ADO have recordset objects, along with other objects that share the same name but different methods and properties. If you don't specify the object model, Access tries to use the first one in its references list, which means that it can easily guess wrong. From the error you got, the ADO reference is higher in the list than DAO, and the ADO recordset object doesn't have an Edit method.

    If you don't have both references set, it isn't necessary to specify the object model, but it's always a good idea since you may want to use the code in a database that does have both object models referenced.
    Charlotte

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Basic DAO Question (A2K SR1)

    Where does one learn about all the ADO methods?
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Basic DAO Question (A2K SR1)

    The methods and properties depend somewhat on the provider. I love ADO, but it can be very frustrating when you switch back and forth between Jet and SQL Server, XML, etc. ADO provides for whatever the individual provider exposes, and every provider builds on the basic (skinny) ADO model and extends it. For the basics, there are several good books like Russell Sinclair's Access to SQL Server and The Visual Basic Developer's Guide to ADO by Mike Gunderloy. I've got so many books by now, that I've lost track of which ones to recommend. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15> You might rummage around in Books and EZines. There have been several threads there and also in VB/VBA on ADO books.
    Charlotte

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Basic DAO Question (A2K SR1)

    Not from the Help files!!

    In an effort to enhance my non-existent knowledge of ADO I recently got a copy of Programming ADO published by Microsoft Press. It's a good, detailed introduction to ADO for us dummies who may know about DAO but nothing about ADO. (The book's stated skill level is "Intermediate/Advanced.") The author, David Sceppa, is described as a "Microsoft Visual Basic database support professional." Maybe they should have put him to work on the "Help" files. (The author admits that ADO documentation is lacking, primarily because the MS data access component development team has been operating in a "ship now, document later" mode for a long time....)

  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Basic DAO Question (A2K SR1)

    Thanks Charlotte and Mark, I appreciate your help.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Basic DAO Question (A2K SR1)

    Good recommendation, Mark. I've got that one around somewhere too! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

  10. #10
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Basic DAO Question (A2K SR1)

    And if plain 'ole ADO isn't enough to keep you busy remember there's ADO.NET lurking around out there, just waiting for unsuspecting new victims.... <img src=/S/flee.gif border=0 alt=flee width=25 height=25>

Posting Permissions

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