Change a field property via VBA?? 
Author Message
 Change a field property via VBA??

Hi,
I want to change a table field's property from Text to Date/Time  Short Date
setting.  I can't find any book that describes how to do it.

If the table's name is TableX and the field's name is FieldY, what would the
code be?  
Thank you!!



Thu, 21 Nov 2002 03:00:00 GMT  
 Change a field property via VBA??
You can't change a field's type once it has been appended to a Fields
collection. You have to create a new field, copy the data across, then
delete the old field.

Simon Lewis


Quote:
> Hi,
> I want to change a table field's property from Text to Date/Time  Short
Date
> setting.  I can't find any book that describes how to do it.

> If the table's name is TableX and the field's name is FieldY, what would
the
> code be?
> Thank you!!



Thu, 21 Nov 2002 03:00:00 GMT  
 Change a field property via VBA??
I'm not sure that I fully understand your question.  I'm not sure
why you want to modify the table definition in code rather than
using Access.  However, one technique that I have tried when
I am upgrading versions of an application and I have to change
my database schema is as follows:

1.  I create a new table def, copy the data from one table to the
     new table (with the appropropriate data conversion written into
     my action query)
2.  Delete (or rename - this is safer!) the old table
3.  Rename the new table.

I'm sure that you could change the data type in code, however
if there is existing data in the table when you change the data type,
Access/Jet might make some noise about it.

To learn about changing data types in code, check the following
topic in the DAO Reference:

    Field Object, Fields Collection Summary

Then scroll down to Type and study that topic.

Hope this helps,

David


Quote:
> Hi,
> I want to change a table field's property from Text to Date/Time  Short
Date
> setting.  I can't find any book that describes how to do it.

> If the table's name is TableX and the field's name is FieldY, what would
the
> code be?
> Thank you!!



Fri, 22 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Set Field Properties via VBA ?

2. Changing Field Properties via ADO 3.6

3. Changing Field Properties via DAO 3.6

4. Change field's Size property via code

5. Changing Field Properties via DAO 3.6

6. how do I access project properties (values) via VBA

7. Setting Printer Properties via VBA

8. accessing the properties of an embedded mscal object via VBA

9. Retrieve AutoNumber field property via code?

10. Adding special fields' properties via code

11. Add Field via DAO - Set Format Property

12. Field Description property via ADO

 

 
Powered by phpBB® Forum Software