Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / August 2004

Tip: Looking for answers? Try searching our database.

Alter tables via code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 04 Aug 2004 10:31 GMT
HI there,

I need to be able to add a new field to my table and
change the data types of certain fields by using code.

Any Ideas?
Allen Browne - 04 Aug 2004 15:48 GMT
These examples show how to use a DDL query statement to:
   - change the size of a field;
   - change the data type of a field;
   - add a new field to a table;
   - remove a field from a table:

ALTER TABLE MyTable ALTER COLUMN MyText2Change TEXT(100);
ALTER TABLE MyTable ALTER COLUMN MyField DOUBLE;
ALTER TABLE MyTable ADD COLUMN SomeNewField TEXT(60);
ALTER TABLE MyTable DROP COLUMN SomeNewField;

You can execute a string using DAO
   dbEngine(0)(0).Execute strSQL
or ADO:
   CurrentProject.Connection.Execute strSql

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> HI there,
>
> I need to be able to add a new field to my table and
> change the data types of certain fields by using code.
>
> Any Ideas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.