Results 1 to 6 of 6

Thread: DAO Recordsets

  1. #1
    penn
    Guest

    DAO Recordsets

    Hi,
    Could someone please remind me of the proper way of declaring and then creating DAO recordsets. I've just transferred one of my databases from an NT4 network using Office 2000 to my laptop Windows 2000 - Office 2000 professional and I think the reason it isn't working is my lazy declarations.

    Thank you very much

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

    Re: DAO Recordsets

    If you converted the database, you should already have a DAO reference set, so if you remove any ADO reference, your code should continue to work. However, the correct method is to specifically declare your DAO-specific objects like this:

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim tdf As DAO.TableDef
    ...etc.

    I use this for all the DAO-specific objects, even if they *don't* exist in ADO because then the engine doesn't have to figure it out.

    For ADO objects, you declare them like this:

    Dim rst As ADODB.Recordset
    Dim cnn AS ADODB.Connection
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table
    ...etc.
    Charlotte

  3. #3
    penn
    Guest

    Re: DAO Recordsets

    Cheers Charlotte,

    The database was giving me a type mismatch when I ran it so I'll wiz through and declare my recordsets properly.

    Thanks again

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

    Re: DAO Recordsets

    Don't forget to check your references and add that DAO reference. Otherwise, your declarations won't make any difference.
    Charlotte

  5. #5
    penn
    Guest

    Re: DAO Recordsets

    Cheers Charlotte,
    You're a star <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>. All is now working beautifully (and a good thing you reminded me to check my references - I obviously didn't save them when I first did it).

    You guys are a fantastic help to scared access novices. By far the best, friendliest, most helpfull web site I've ever encountered, and I've been to some where they were downright rude. Thanks a lot <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: DAO Recordsets

    Woody and Eileen maintain a great site, and we're all happy to do our part. Glad your problem is solved, but feel free to post any others that you encounter.
    Charlotte

Posting Permissions

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