Re: Creating a recordset of a table in an external database
From: Marshall Barton (marshbarton_at_wowway.com)
Date: 03/27/05
- Next message: Shadow: "Re: Summery query question"
- Previous message: Allen Browne: "Re: Searchform including related tabels."
- In reply to: Shadow: "Creating a recordset of a table in an external database"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Mar 2005 08:53:33 -0600
Shadow wrote:
>I have two databases and each one contains several
>tables, forms.......(database A and database b)
>I need to create a recordset of a table in database A while I'm running some
>vba codes in a module in database B.
>While the following code creates a recordset from a table in current
>database, how can I create a recordset from a table in an external database?
>set db=currentdb
>set rst=db.openrecordset("tblname")
A couple of other ways to do this. The easiest is to link
to the other database's table using the File - Get External
Data - Link menu item. Then just open the recordset as if
the table were in the local db:
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblname", dbOpenDynaset)
Another is to open the remote table using an SQL statement
that uses the IN phrase in its FROM clause:
Set db = CurrentDb()
strSQL = "SELECT * FROM tblname IN ""C:\path\B.mdb"""
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
In most cases, you don't really need to use
OpenDatabase("C:\path\B.mdb") unless you require the
recordset to be opened with dbOpenTable.
-- Marsh MVP [MS Access]
- Next message: Shadow: "Re: Summery query question"
- Previous message: Allen Browne: "Re: Searchform including related tabels."
- In reply to: Shadow: "Creating a recordset of a table in an external database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|