By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

How to access another database in my application

P: 30
i want to access values of another database in my vba application

how to use it

can anybody give me sample code....
Aug 17 '12 #1

✓ answered by TheSmileyCoder

Linked tables are a fine solution if your always connecting to the same database. However there might be cases where you need to access information from a file selected by the user. In such cases you can either use OpenDatabase from your VBA environment, and then open recordsets from that database.

If you simply need to lookup data or even edit data, you can also open a recordset directly against another database from within the query syntax.

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tbl_Example in 'C:\TestFolder\TestDatabase.mdb'
I believe that is the correct syntax but otherwise it should be a simple matter to look it up.

Share this Question
Share on Google+
4 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,068
The easiest way is to link the tables of the other database with your current database.
Aug 17 '12 #2

zmbd
Expert Mod 5K+
P: 5,287
Prasad:
Twinny for is correct. You will need to link to the tables witin the other database in as much as you would to any backend database. You use the linked tables in the same way you any such set of datatables.


-z
Aug 17 '12 #3

ariful alam
100+
P: 185
@joshi,

create linked table to other database file to access the tables of that database file.
Aug 17 '12 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
Linked tables are a fine solution if your always connecting to the same database. However there might be cases where you need to access information from a file selected by the user. In such cases you can either use OpenDatabase from your VBA environment, and then open recordsets from that database.

If you simply need to lookup data or even edit data, you can also open a recordset directly against another database from within the query syntax.

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tbl_Example in 'C:\TestFolder\TestDatabase.mdb'
I believe that is the correct syntax but otherwise it should be a simple matter to look it up.
Aug 17 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.