Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Working with Data from an External Database (A2K)

    I don't even know if this is possible, but I thought I'd throw it out there. (I hate to post AGAIN this week. I'm already humbled for all of the help Hans has given me over the past couple of weeks!)

    Here's the question: Is it possible to use data from an external Access database as the recordsource on a form without linking/importing the table?

    Here's what I'm doing: In my code I'm already referencing the external database with Set db = DBEngine.Workspaces(0).OpenDatabase(strFilename)
    where strFilename is the path to the database. I then use SQL statements to work with the actual data like this:
    strSQL = "SELECT " & strTbl & ".* FROM " & strTbl & ";"
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset) where strTbl is obviously the name of the table I need to work with.

    I'd like to display the records in a form. I can't just set the SQL string as the forms recordsource for several reasons - the main one being that the SQL string itself doesn't reference the external database.

    I realize I might just have to link to the table, but I've done a lot of work to avoid doing that (no real reason, just seeing how well it can be done) and I hate to have to do that now.

    Any thoughts? Suggestions?
    Thanks!
    Sam

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Working with Data from an External Database (A2K)

    You could create a query with an SQL statement like this:

    SELECT * FROM T_ImportDetail IN 'R:CompengMasterDataCE_ExternalData.mdb'

    substituting the correct path for the database, and use the query (or the SQL statement itself) as record source for the form.

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with Data from an External Database (A

    Ahh! The IN clause! How cool. I'm starting to see the power of SQL statements!

    Thanks, Hans!
    Sam

Posting Permissions

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