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  

Q: programmatically add/modify fields?



 
 
Thread Tools Display Modes
  #1  
Old February 2nd, 2005, 12:55 AM
MarkD
external usenet poster
 
Posts: n/a
Default Q: programmatically add/modify fields?

Using Access 2000.

I want to programmatically add a field to a table and
modify another field. Can I write an ALTER TABLE
statement, or do I have to change it via tabledef?

Also, one of the fields we change from text to numeric,
which invalidates some data (which is okay). Right now, I
open the table in design mode, change the field, save the
table. Access warns of the error and I just accept it.

Will I be able to change the field in SQL (or via
tabledef), or will these invalid values cause Access to
not allow me to do that?
  #2  
Old February 2nd, 2005, 03:26 AM
Allen Browne
external usenet poster
 
Posts: n/a
Default

You can execute a DDL query statement
dbEngine(0)(0).Execute "ALTER TABLE ...", dbFailOnError

From memory that just loses any data that no longer fits (e.g. non-numeric
data if you ALTER COLUMN to a number).

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

"MarkD" wrote in message
...
Using Access 2000.

I want to programmatically add a field to a table and
modify another field. Can I write an ALTER TABLE
statement, or do I have to change it via tabledef?

Also, one of the fields we change from text to numeric,
which invalidates some data (which is okay). Right now, I
open the table in design mode, change the field, save the
table. Access warns of the error and I just accept it.

Will I be able to change the field in SQL (or via
tabledef), or will these invalid values cause Access to
not allow me to do that?



  #3  
Old February 3rd, 2005, 01:19 AM
MarkD
external usenet poster
 
Posts: n/a
Default

Cool! Thanks much.

-Mark


-----Original Message-----
You can execute a DDL query statement
dbEngine(0)(0).Execute "ALTER TABLE ...",

dbFailOnError

From memory that just loses any data that no longer fits

(e.g. non-numeric
data if you ALTER COLUMN to a number).

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

"MarkD" wrote in

message
...
Using Access 2000.

I want to programmatically add a field to a table and
modify another field. Can I write an ALTER TABLE
statement, or do I have to change it via tabledef?

Also, one of the fields we change from text to numeric,
which invalidates some data (which is okay). Right now,

I
open the table in design mode, change the field, save

the
table. Access warns of the error and I just accept it.

Will I be able to change the field in SQL (or via
tabledef), or will these invalid values cause Access to
not allow me to do that?



.

 




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
Outlook contacts doesn't allow all fields from Excel? gnmcewen Contacts 0 January 9th, 2005 05:21 AM
Additional fields for form based parameter query/null fields geeksdoitbetter Running & Setting Up Queries 2 January 7th, 2005 11:05 PM
Populate fields in Form Header based on header fields in startup f Pat Dools Using Forms 0 January 7th, 2005 04:19 PM
Automatic filling of fields in table two from table one Jim Kelly Database Design 1 September 27th, 2004 10:16 PM
How to Delete Custom Fields Programmatically in Contact Ajay Contacts 1 June 28th, 2004 04:56 PM


All times are GMT +1. The time now is 10:01 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.