Access external DB in VBA 
Author Message
 Access external DB in VBA

Hi, I have two databases that share the same information,
i wish to use VBA in the second to get the relevant
information from the initial database as and when i need
it, hence, no link tables.  I have played around the
following lines, but cant get it to work, can anybody help?

dim rs, connect as object
dim sql as string

set rs = createobject ("ADODB.recordset")
set connect = "l:\\accsapps\sea2k_be.mdb"

sql = "select * from [T_Participant] where [Surname]
="Jones""

rs.open sql, connect,1



Mon, 17 Jan 2005 16:36:57 GMT  
 Access external DB in VBA
Hi,

You can use two database objects with the following  code:

dim dbs_far as DAO.database
dim rst_far as DAO.recordset

set dbs_far = opendatabase("Name of the far Db")
set rst_far = dbs_far.openrecordset(sql)

Idon't understand the remaining code because i'm not good enough but with
the previous code you are connected with the database if there is no
password.

If there is a password to access your distant database, then see
opendatabase's Help.

good Luck!
Francois.


Quote:
> Hi, I have two databases that share the same information,
> i wish to use VBA in the second to get the relevant
> information from the initial database as and when i need
> it, hence, no link tables.  I have played around the
> following lines, but cant get it to work, can anybody help?

> dim rs, connect as object
> dim sql as string

> set rs = createobject ("ADODB.recordset")
> set connect = "l:\\accsapps\sea2k_be.mdb"

> sql = "select * from [T_Participant] where [Surname]
> ="Jones""

> rs.open sql, connect,1



Mon, 17 Jan 2005 20:51:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Backing up tables to external access db's

2. Linking External DB to Access (Follow-up)

3. Can I use VBA to manipulate external MS-ACCESS database

4. Access current DB in VBA script

5. Accessing a secured db via VBA?

6. Increase spead adding Access db Record to Word VBA listbox

7. Duplicate an Access DB via VBA

8. VBA: linking a table from a secured access-db

9. Connect to Access DB from outlook VBA

10. Why can't I open an Access DB in VBA

11. Compacting an Access DB with VBA

12. Sorting access db w/VBA

 

 
Powered by phpBB® Forum Software