[AccessD] Set a field data type via code

Gina Hoopes hoopesg at hotmail.com
Wed Oct 22 08:32:49 CDT 2003


Thanks, Bryan.  I'm going to give that a try.

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?

On 21 Oct 2003 at 16:26, Reuben Cummings wrote:

>Based on our work on the Back End Upgrader, in order to change a
data
>type thru code you will need to create a new field, move the data
to
>the new field, delete the original field, and rename the new field.


Um, you aren't going to believe this Reuben but:

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.

_________________________________________________________________
Concerned that messages may bounce because your Hotmail account has exceeded 
its 2MB storage limit? Get Hotmail Extra Storage!         
http://join.msn.com/?PAGE=features/es



More information about the AccessD mailing list