Cannot execute data definition statements on linked data sources

G

Guest

I receive the error message in the subject line when I try to run the
following SQL

ALTER TABLE tblProgDeliv ADD COLUMN [TechID] NUMBER [LONG INTEGER]

TechID would be a foreign key to the Tech table, where it is the primary
key, and is used as a FK in existing tables as well.

Any suggestions on how to accomplish the above via some form of SQL or code
will be gratefully accepted.
 
A

Allen Browne

tblProgDeliv is an attached table in some other file.

You will need to OpenDatabase on that file to modify the table:

Dim db As DAO.Database
Dim strSql As String
strSql = "ALTER TABLE ...
Set db = OpenDatabase("C:\MyFolder\MyFile.mdb")
db.Execute strSql, dbFailOnError
db.Close
set db = nothing
 
G

Guest

Thanks for the response. I would have mentioned that I was trying to modify a
table in the back-end database, but it only dawned on me what the error
message meant about 15 seconds after I posted my question. Couldn't see the
forest for the trees. I figured I would need to use an OpenDatabase command.
Your code will save me a lot of time. Thanks again.

Allen Browne said:
tblProgDeliv is an attached table in some other file.

You will need to OpenDatabase on that file to modify the table:

Dim db As DAO.Database
Dim strSql As String
strSql = "ALTER TABLE ...
Set db = OpenDatabase("C:\MyFolder\MyFile.mdb")
db.Execute strSql, dbFailOnError
db.Close
set db = nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

RWilly said:
I receive the error message in the subject line when I try to run the
following SQL

ALTER TABLE tblProgDeliv ADD COLUMN [TechID] NUMBER [LONG INTEGER]

TechID would be a foreign key to the Tech table, where it is the primary
key, and is used as a FK in existing tables as well.

Any suggestions on how to accomplish the above via some form of SQL or
code
will be gratefully accepted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top