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

SQL (ALTER TABLE doesn't work)

P: n/a
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
@ndy wrote:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Try using an import spec and skip some columns. Altertatively leave the
column alone and use a query that doesn't include it if it's presence
upsets you that much. :-)
--
This sig left intentionally blank
Nov 13 '05 #2

P: n/a
@ndy wrote:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Sub DropColumn(cTable As String, cColumn As String)
Dim td As TableDef
Dim db As Database
Set db = CurrentDb
Set td = db.TableDefs(cTable)
td.Fields.Delete cColumn
Set td = Nothing
Set db = Nothing
End Sub

that works. It doesn't test, you should enter correct values!

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3

P: n/a
"@ndy" <an*******@hotmail.com> wrote in message
news:6c**************************@posting.google.c om...
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


What is the error message? Are you using the column in an index or primary
key constraint?
Nov 13 '05 #4

P: n/a
On Dec 03 2004, 03:09 am, an*******@hotmail.com (@ndy) wrote in
news:6c**************************@posting.google.c om:
I import an excel sheet to access and know i won't to delete some
columns. This my code that doesn't work.

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder"
DoCmd.RunSQL strSQLAlter


Because the column name contains a minus sign, it has to be enclosed in
square brackets:

strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN [Dossier-beheerder]"

--
remove a 9 to reply by email
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.