
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