Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Location
    Australia
    Posts
    5

    Angry DAO Recordset Connection for Access 2002

    Hi All,



    I have an access 2002 database with one table in it called "MT_ITEM_LIST" and have added the ADO 3.6 Library to my source references.

    I am trying to connect to the table but my code trips up when I try to Open the recordset.

    My Current code is as follows:

    Public Function searchTable()

    Dim dbs As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDbs("MT_ITEM_LIST")
    Set rs = dbs.OpenRecordset("MT_ITEM_LIST", dbOpenDynaset)

    Dim strSql As String
    Dim strSQL2 As String

    Dim vSearchItemRef, vSearchItemDesc, vSearchPVNb
    Dim vResultItemRef, vResultDC, vResultItemDesc, vResultPVNb, vResultPVName

    strSql = "My Test SQL"

    Debug.Print strSql

    *** CODE TRIPS UP HERE ***
    rs.Open strSql, conn, adOpenKeyset, adLockOptimistic

    Any suggestions for me?

    Thanks.
    Last edited by creativefusion; 08-17-2010 at 05:42 PM. Reason: Correction

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I think we need a little clarity here. Your title mentions a DAO recordset but then you mention adding an ADO reference (unless that's a typo, since it's the DAO reference that's at 3.6).

    In your code, you declare a DAO recordset, but the line of code that is throwing the error is the syntax to open an ADO recordset. This line by the way is typically:

    Set db = CurrentDb

    I don't know that what you have is valid syntax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Oct 2009
    Location
    Australia
    Posts
    5
    Hi Paul,

    You are correct. A typo on my part. It should be DAO not ADO.

    Following your response, I see the my syntax is incorrect.

    I have not corrected it but still cannot connect to the DB.

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("MT_ITEM_DC_LIST", dbOpenDynaset)

    Dim strSql As String
    Dim strSQL2 As String

    strSql = "My SQL"

    'Error happends here
    rs.Open strSql, conn, adOpenKeyset, adLockOptimistic

    Am I missing something abvious? I am still a newbie at this stuff and have been trained only on ADODB connections...

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Like I said, this:

    rs.Open strSql, conn, adOpenKeyset, adLockOptimistic

    is ADO syntax, not DAO. You've already set rs above anyway, with this line:

    Set rs = db.OpenRecordset("MT_ITEM_DC_LIST", dbOpenDynaset)

    so I'm not sure what the line that is throwing the error is intended to do.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Oct 2009
    Location
    Australia
    Posts
    5
    Hi Paul,

    Thanks for this I have got it working now.

    Regards,
    CF

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access 2002 runtime problems
    By Drisconsult in forum Programming
    Replies: 2
    Last Post: 07-24-2010, 03:57 AM
  2. Old Access 2002 Application
    By billpl in forum Access
    Replies: 4
    Last Post: 02-19-2010, 07:51 AM
  3. Access 2002 ADP application in VSS
    By Accessdev in forum Access
    Replies: 0
    Last Post: 12-16-2009, 12:52 PM
  4. where is access 2002?
    By anon125 in forum Access
    Replies: 1
    Last Post: 08-16-2009, 10:42 AM
  5. Convened Access 2002 database to SQL
    By caljohn527 in forum Queries
    Replies: 0
    Last Post: 01-31-2009, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums