[AccessD] Set a field data type via code

Bryan Carbonnell carbonnb at sympatico.ca
Tue Oct 21 19:19:02 CDT 2003


> > -----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.




More information about the AccessD mailing list