|
-
Mar 2nd, 2002, 06:18 PM
#1
Thread Starter
New Member
Replicate a field via DAO
All,
I need to change the size of a field via DAO. I know how to delete a field and then create a new one, but what I can't seem to work out is how to create a new field, copy the data from the old field and then rename the new field.
So, I have a field which is 50 characters in size which contains data and I want to make the field 75 characters wide, BUT, retain the existing data.
Could anyone give me a few pointers ?
Thanks.
Chris Swann
-
Mar 3rd, 2002, 03:56 AM
#2
Hyperactive Member
try gab2001uk's site, in part of his project he goes over copying a database field by field. It's not exactly what you were asking for but it contains all the info you will need to do what you want to.
http://homepage.ntlworld.com/graham-bridge/visualbasic/daovsado/index.htm
-
Mar 3rd, 2002, 10:19 AM
#3
Well ...
Originally posted by dc8
All,
I need to change the size of a field via DAO. I know how to delete a field and then create a new one, but what I can't seem to work out is how to create a new field, copy the data from the old field and then rename the new field.
So, I have a field which is 50 characters in size which contains data and I want to make the field 75 characters wide, BUT, retain the existing data.
Could anyone give me a few pointers ?
Thanks.
Chris Swann
You can do that specific job using an Alter Table SQL statement too. If you want to do it through DAO, it's a tad complicated:
Dim myField As New Field
Then copy all applicable attributes of the original field into this using:
MyField.Name = OldField.Name
MyField.AllowZeroLength = OldField.AllowZeroLength
etc.
Then append this MyField to your TableDef object using tabledef.fields.append myfield. Then copy all existing data in the old field into this new field. Once that's done, drop the old field using tabledef.fields.remove. Then once again go through the same process above, only this time changing the Size of the new field object to your new size. Rest of the steps as they are.
.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|