[AccessD] Set a field data type via code

Gina Hoopes hoopesg at hotmail.com
Wed Oct 22 12:13:12 CDT 2003


Bryan, this worked perfectly.  Thank you!

Gina

-----Original Message-----
From: Bryan Carbonnell [mailto:carbonnb at sympatico.ca]
Sent: Tuesday, October 21, 2003 7:19 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Set a field data type via code



> > -----Original Message-----

> > > Is it possible to use code (cbf) to change a field's data type, in > > 
>the
> > table itself, from number to text?


In A2K, with DAO referenced you can use ALTER TABLE to do it:

Dim strSQL As String
Dim db As DAO.Database

Set db = CurrentDb()
strSQL = "ALTER TABLE Table1 ALTER COLUMN fldText CHAR(10);"

db.Execute (strSQL)

Set db = Nothing

Where CHAR(10) indicated that it is being changed to a text field
with a length of 10 characters.

In my test fldText started out as a Long Integer field.

--
Bryan Carbonnell - carbonnb at sympatico.ca
Never let a computer see you hurry.

_________________________________________________________________
Surf and talk on the phone at the same time with broadband Internet access. 
Get high-speed for as low as $29.95/month (depending on the local service 
providers in your area).  https://broadband.msn.com



More information about the AccessD mailing list