A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Alter tables via code



 
 
Thread Tools Display Modes
  #1  
Old August 4th, 2004, 10:31 AM
Bob
external usenet poster
 
Posts: n/a
Default Alter tables via code

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?
  #2  
Old August 4th, 2004, 03:48 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default Alter tables via code

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

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

"Bob" wrote in message
...
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?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing a form and all of the module code for it Jack Gillis General Discussion 4 July 25th, 2004 07:07 PM
VBA Code Help - Badly needed venus as a boy General Discussion 1 July 20th, 2004 06:53 PM
Hi! Urgent pls: Protecting sheets so macros/buttons still work? StargateFanFromWork General Discussion 7 July 3rd, 2004 02:25 PM
searching for "join tables" and "join word tables" Uncle Bill Tables 1 June 11th, 2004 09:33 PM
Multiple Many-To-Many Tables Tom Database Design 7 May 15th, 2004 03:47 AM


All times are GMT +1. The time now is 10:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.