Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - vbscript to alter table in msaccess

Reply
 
Old 06-05-2009   #1 (permalink)
jagoa21


 
 

vbscript to alter table in msaccess

I have am trying to update two tables one updates just fine but for
some reason I get an error on the other. Anyway ideas what going on
would be helpful. The script is dying at this line
"objAccess.DoCmd.RunSQL "ALTER TABLE image ALTER COLUMN COMMENT TEXT
(40)".

Error below:

Windows Script Host

Script: C:\myfolder\script.vbs
Line: 10
Char: 1
Error: Syntax error in ALTER TABLE statement.
Code: 800A0CDD
Source: (null)



Srcipt below:


Set objAccess = CreateObject("Access.Application")

objAccess.AutomationSecurity = 1 ' msoAutomationSecurityLow

objAccess.OpenCurrentDatabase "C:\mydatabase.mdb"
Set db = objAccess.CurrentDB

objAccess.DoCmd.RunSQL "ALTER TABLE mytable ALTER COLUMN FILE TEXT
(50)"
objAccess.DoCmd.RunSQL "ALTER TABLE mytable ALTER COLUMN FILE TEXT
(50)"
objAccess.DoCmd.RunSQL "ALTER TABLE image ALTER COLUMN COMMENT TEXT
(40)"

objAccess.AutomationSecurity = 2 ' reset

My System SpecsSystem Spec
Old 06-05-2009   #2 (permalink)
Jason


 
 

Re: vbscript to alter table in msaccess

On Jun 5, 9:12 am, jago...@xxxxxx wrote:
Quote:

> I have am trying to update two tables one updates just fine but for
> some reason I get an error on the other. Anyway ideas what going on
> would be helpful. The script is dying at this line
> "objAccess.DoCmd.RunSQL "ALTER TABLE image ALTER COLUMN COMMENT TEXT
> (40)".
>
> Error below:
>
> Windows Script Host
>
> Script: C:\myfolder\script.vbs
> Line: 10
> Char: 1
> Error: Syntax error in ALTER TABLE statement.
> Code: 800A0CDD
> Source: (null)
>
> Srcipt below:
>
> Set objAccess = CreateObject("Access.Application")
>
> objAccess.AutomationSecurity = 1 ' msoAutomationSecurityLow
>
> objAccess.OpenCurrentDatabase "C:\mydatabase.mdb"
> Set db = objAccess.CurrentDB
>
> objAccess.DoCmd.RunSQL "ALTER TABLE mytable ALTER COLUMN FILE TEXT
> (50)"
> objAccess.DoCmd.RunSQL "ALTER TABLE mytable ALTER COLUMN FILE TEXT
> (50)"
> objAccess.DoCmd.RunSQL "ALTER TABLE image ALTER COLUMN COMMENT TEXT
> (40)"
>
> objAccess.AutomationSecurity = 2 ' reset
"image" is a data type in SQL. Try enclosing it in brackets [image] so
it is parsed properly as a table name rather than a data type.
My System SpecsSystem Spec
Old 06-05-2009   #3 (permalink)
Jay


 
 

Re: vbscript to alter table in msaccess

Hi Jason,

Thank you for the help. It is always the little things. All is
running smoothly now.


Jay
My System SpecsSystem Spec
Old 06-05-2009   #4 (permalink)
Bob Barrows


 
 

Re: vbscript to alter table in msaccess

Jay wrote:
Quote:

> Hi Jason,
>
> Thank you for the help. It is always the little things. All is
> running smoothly now.
>
>
Don't use "image", or any other reserved keyword, as an object name - it
will bite you in the behind sooner or later.
--
HTH,
Bob Barrows


My System SpecsSystem Spec
Old 06-05-2009   #5 (permalink)
Jay


 
 

Re: vbscript to alter table in msaccess

Thank you Bob. Issues do come up when you are not paying attention.


Jay.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Typed datasets and table table adapters components not showing inToolbox .NET General
Exporting MsSQL table to Excel using vbScript? VB Script
how do you create a dynamic table/pivot table .NET General
Opening an MSAccess DB .NET General
run msaccess macro from PS PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46