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

Create Table / Modify Table in remote database

P: n/a
I'm using Access XP.

I'm trying to create a table, modify a table, create in index, and create a
relationship in a remote database in code from the program database.

I know how to create and manipulate resident tables using code but not a
remote or attached database.

Any help you could provide would be greatly appreciated

Thank you!
Jo
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You need to open the remote database as an object.

Dim objAcc As Access.Application
Dim extDB As DAO.Database
Set objAcc = GetObject(strRemoteDB_FileName)
Set extDB = objAcc.CurrentDb
From there, you can do anything you need to do in extDB (the "remote"

database) as if it was the local database. Just remember to preface
your commands with "extDB." or "objAcc." (depending upon what level you
need to operate at) so Access doesn't try to do it in the local DB.

objAcc.DoCmd.DeleteObject <whatever>
or
extDB.Execute <SQL string>,dbFailOnError

As always, remember to close and set to nothing your objects.

Oh, and a warning... Remember to make a _copy_ of the remote database
before doing anything to it! This will give you a chance to abort
whatever you are doing if (when!) something unexpected happens (and
experience says: it will.)

Nov 13 '05 #2

P: n/a
Thanks Chuck, I'll give that a try.
"Chuck Grimsby" <c.*******@worldnet.att.net> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
You need to open the remote database as an object.

Dim objAcc As Access.Application
Dim extDB As DAO.Database
Set objAcc = GetObject(strRemoteDB_FileName)
Set extDB = objAcc.CurrentDb
From there, you can do anything you need to do in extDB (the "remote"

database) as if it was the local database. Just remember to preface
your commands with "extDB." or "objAcc." (depending upon what level you
need to operate at) so Access doesn't try to do it in the local DB.

objAcc.DoCmd.DeleteObject <whatever>
or
extDB.Execute <SQL string>,dbFailOnError

As always, remember to close and set to nothing your objects.

Oh, and a warning... Remember to make a _copy_ of the remote database
before doing anything to it! This will give you a chance to abort
whatever you are doing if (when!) something unexpected happens (and
experience says: it will.)

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.