Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query external database

Status
Not open for further replies.

Stoffel24

Technical User
Apr 4, 2002
121
ZA
Hi all

I have a requirement to query a table in an external database. I have created a connection to this external database as shown below (Data_source is the external database path):

Set dbDoc = DBEngine.Workspaces(0).OpenDatabase(Data_Source)

Now I need to query a table called Field_master in Data_source. I have 2 questions:

1) Should I do this with a sql command or use an openrecordset or what?

2) Once I have queried this database, if I do it with a sql command and I return the 2 fields I need (call them field1 and field2) how do I extract the appropriate one?

Thanks in advance...
 
Probably the easiest way to do this is to link the tables in the external database into your access database. You can then use the linked tables as if they were local Access tables and create queries, forms, reports, etc. as you would do normally.

hth

Ben

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
The problem is that the database I link to is not constant so I would prefer to link to it dynamically using code. Alternatively, I would have to create this link as you describe but make the database I link to change with code.
 
Linked tables can be updated from either database and updates are reflected in either database as well...

It sounds like linking tables will easily meet your needs...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top