VBA Access missing reference?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • richhemmings
    New Member
    • Mar 2006
    • 3

    #1

    VBA Access missing reference?

    Hi,
    am having issues with a 'simple' bit of code:-

    Private Sub Command2_Click( )

    Dim rs As Recordset

    Set rs = CurrentDb.OpenR ecordset("tbl - availability")

    rs.Close

    End Sub

    I get a type mismatch error!
    I was reading another thread that said about the references?
    I currently have;
    Visual Basic for Applications
    Microsoft Access 10.0 Object Library
    OLE Animation
    Microsoft ActiveX Data Objects 2.1 Library

    should there be any more? and if so, how do I het them??

    Cheers,

    Rich
  • bnettmd
    New Member
    • Aug 2006
    • 1

    #2
    Originally posted by richhemmings
    Hi,
    am having issues with a 'simple' bit of code:-

    Private Sub Command2_Click( )

    Dim rs As Recordset

    Set rs = CurrentDb.OpenR ecordset("tbl - availability")

    rs.Close

    End Sub

    I get a type mismatch error!
    I was reading another thread that said about the references?
    I currently have;
    Visual Basic for Applications
    Microsoft Access 10.0 Object Library
    OLE Animation
    Microsoft ActiveX Data Objects 2.1 Library

    should there be any more? and if so, how do I het them??

    Cheers,

    Rich
    Rich,

    You're probably passed this issue by now but
    I would remove the reference to 'Microsoft ActiveX Data Objects 2.1 Library', add a reference to 'Microsoft DAO 3.51 (or higher) Object Library' and use the following syntax.

    Private Sub Command2_Click( )

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Set db = CurrentDb
    Set rs = db.OpenRecordse t("tbl - availability")

    rs.Close

    End Sub

    Good Luck,
    Marty

    Comment

    Working...