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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open another access database 1

Status
Not open for further replies.

jmodo

Programmer
Aug 2, 2006
43
US
Inside database A, I need to open datbase B to run SQL statements. Where can I find references for this?
 
Are you trying to return values to DBA? Why not just link the database tables from B or for that matter link the reports and queries from B as well.

What exactly are you trying to accomplish? What is the business practice behind your request. It is a little vague in the reason necessary to actually open the other DB.

Other options include an ADO connection to DBb and execute sql statements from within A.



Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
I know it should be something like this:
Dim theDBS as DAO.Database
Dim theRST as DAO.Recordset

openconn theDBS= ???Application.CurrentDb?????
theDBS.Execute sqlString
 
I am trying to run some ALTER TABLE commands to add new fields.

I have a module that I am using to easily update many copies of a database.
 
Something like this should do ya. With reference to ADO. Sorry I have not used DAO in so long it escapes me.


Dim conData As New ADODB.Connection
dim stsql as string

Set conData = CreateObject("ADODB.Connection")
conData.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = "Put the path and db name here"

stsql = "Enter your sql statement here."

condata.execute stsql

This is from memory and of course you should probably add some error trapping as usual.


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Ok thanks! I knew it was something like that, I just couldn't remember where I had the code located.
 
Your welcome. Thanks for the star.

Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top