Results 1 to 3 of 3
  1. #1
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44

    Database object of currenly open Access 2007 DB


    I am trying to retrieve a Recordset for a table in the currently open Access 2007 database. However, the RecordSet method, requires a database object. I know that the syntax I need is

    Set rstIssues = dbs.OpenRecordset("SELECT DISTINCT * FROM Issues WHERE TTP_No = " & lngSelectedTTP)

    where rstIssues is defined as a RecordSet, and dbs is defined as a Database.

    But, since the database is already open, how do I retrieve the value for dbs, without actually performing the OpenDatabase command?

    Set dbs = OpenDatabase("TTP.accdb")

    BTW - When I do perform the OpenDatabase command, I get a msgbox with

    Run time error '3024'
    Could not find file 'TTP.accdb'

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Try:

    Set dbs = CurrentDb

    Or don't bother with the variable.

    Set rstIssues = CurrentDb.OpenRecordset(...)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Great! Didn't know about the CurrentDb variable. Thank you so much!

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

Similar Threads

  1. Access 2007 will not open database
    By IAmNela in forum Access
    Replies: 7
    Last Post: 02-03-2014, 11:56 AM
  2. Unable to open the database in Acess 2007
    By Bhat59 in forum Access
    Replies: 1
    Last Post: 08-09-2012, 07:38 PM
  3. MS 2007 files won't open from VBA in Access 2007
    By gopherking in forum Programming
    Replies: 1
    Last Post: 02-24-2012, 02:44 PM
  4. Replies: 1
    Last Post: 11-15-2010, 06:15 AM
  5. What Database is Open? (Access 2007)
    By jhrBanker in forum Access
    Replies: 3
    Last Post: 06-06-2009, 09:00 AM

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