Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 8th, 2003, 08:12 AM
Authorized User
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing Datatype In Access Database

Is there a way to change the datatype of a field in an Access database table through a SQL statement? I've found a why to do it by adding a new field to the table, copying the data from the field I want to change to the new field, deleting the old field and renaming the new field. This works except the new field is now the last field on the table. I want the field to stay in the same place in the table. Is there a way to do this with SQL or through VB code?
Old October 8th, 2003, 11:03 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

ALTER TABLE Table1 ALTER COLUMN Field1 Text (50);

I used this to change a field name 'Field1' in 'Table1' from a number data type to a text data type 50 characters long.



Old October 8th, 2003, 11:53 AM
Authorized User
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

That works! Thanks!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing database at runtime joerage BOOK: Professional Crystal Reports for VS.NET 3 December 15th, 2006 05:55 PM
Changing column datatype abelmirma Access VBA 1 January 16th, 2006 07:25 PM
Changing Database for Crystal Reports pavel Pro VB 6 4 December 5th, 2005 01:58 PM
Changing Database. rupen Classic ASP Basics 3 July 12th, 2005 06:02 PM
Changing Datatype In Access Database fastcorvette Pro VB 6 9 October 8th, 2003 11:57 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.