A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Cannot execute data definition statements on linked data sources



 
 
Thread Tools Display Modes
  #1  
Old November 21st, 2006, 03:51 PM posted to microsoft.public.access.queries
RWilly
external usenet poster
 
Posts: 4
Default Cannot execute data definition statements on linked data sources

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.
  #2  
Old November 21st, 2006, 03:56 PM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default Cannot execute data definition statements on linked data sources

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
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RWilly" wrote in message
...
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.



  #3  
Old November 21st, 2006, 04:40 PM posted to microsoft.public.access.queries
RWilly
external usenet poster
 
Posts: 4
Default Cannot execute data definition statements on linked data sourc

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" wrote:

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
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RWilly" wrote in message
...
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.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.