Results 1 to 4 of 4
  1. #1
    LegBone is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2

    OpenDatabase()

    I am new to programming Access in VBA however, I have experience using VB6 to open, and manipulate databases. My question has to do with opening databases and tables to run queries.

    In VB I would use this to define and open a database,


    Code:
    Dim DB as Database
    Dim RS as Recordset
    Dim SQL as String
    Set DB = OpenDatabase(somedatabaseName)
    Then I would define a string for my query...
    Code:
    SQL = SELECT * from tblName
    Then I would run the query...
    Code:
    Set RS = DB.OpenRecordset(SQL)
    To start with, do I really need to open the database since I've already opened it when I started access?

    If I don't, then how do I define and open a recordset?

  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,652
    Try

    Set db = CurrentDb
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    LegBone is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2
    Quote Originally Posted by pbaldy View Post
    Try

    Set db = CurrentDb
    Thank you very much...

  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,652
    No problem, and welcome to the site.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

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