I tried to rename a table name by using SQL as:
Dim db As Database
Set db = CurrentDb
db.Execute "ALTER TABLE tabname RENAME new_tabname"
Can you see what is wrong with this code?
I'm using Access 2000.
Thanks
Hoang
HTH, Mike MacSween
"Hoang Vu" <hoan...@vianova.no> wrote in message
news:ap0mgh$1u2$1...@oslo-nntp.eunet.no...
ALTER TABLE table {ADD {COLUMN field type[(size)][NOT NULL][CONSTRAINT
index] |
ALTER COLUMN field type[(size)] |
CONSTRAINT multifieldindex} |
DROP {COLUMN field I CONSTRAINT indexname} }
The syntax does not include a RENAME clause.
You could, however, use Docmd.Rename on a closed database object:
DoCmd.Rename "New Table Name", acTable, "Old Table Name"
--
Gareth Gibbings
Dim db As Database
Set db = CurrentDb
db.TableDefs("tabname").Name = "new_tabname"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Hoang Vu" <hoan...@vianova.no> wrote in message
news:ap0mgh$1u2$1...@oslo-nntp.eunet.no...
Thank you for your answers, but
why I don't want to use Docmd.Rename or db.TableDefs("tabname").Name =
"new_tabname" is
because I would like to move my application from Access to Visual Basic as
stand alone appl.
By using db.Execute we are not depending on DAO or ADO, right?
Gareth and Mike:
The RENAME clause I found is for Visual FoxPro (MSDN)
I also would like to convert my code from DAO to ADO. Is it possible to
modify tables by using ADO?
Hoang
You should also question any renaming solution you decide on.
Consider the effects on referential integrity.
--
Gareth Gibbings
Hoang
"Gareth Gibbings" <gar...@gkgib.demon.co.uk> wrote in message
news:76Z2xwNI...@gkgib.demon.co.uk...
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Hoang Vu" <hoan...@vianova.no> wrote in message
news:ap354r$s6h$1...@oslo-nntp.eunet.no...
db.TableDefs etc. should work in VB. Assuming you want to use DAO, which is
probably still best for a Jet backend.
> By using db.Execute we are not depending on DAO or ADO, right?
It looks to me like your db variable is a database object, so yes you are
using DAO.
> Gareth and Mike:
> The RENAME clause I found is for Visual FoxPro (MSDN)
I think that's a FoxPro command, not a SQL statement. Don't let the CAPITALS
fool you. And why are you referring to the FoxPro help files anyway?
Mike