Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Need to change A Field Size

 
   Database Help (Home) -> Visual Basic -> DAO RSS
Next:  No VB runtime error when SQL statement fails  
Author Message
Michael A. Gunther

External


Since: Feb 06, 2004
Posts: 1



(Msg. 1) Posted: Fri Feb 06, 2004 4:29 pm
Post subject: Need to change A Field Size
Archived from groups: microsoft>public>vb>database>dao (more info?)

I am using DAO. and a field was created and is incorrect in size, was
created at 20 char's and I need it to be 25 chars.

Dim tbfNewRecords as DAO.tabledef
Dim Size as Property

Set tbfNewRecords = datdatabase.tabledefs("New Records")


With tbfNewRecords

If .fields("GMAccount").fieldsize = 20 then
.fields("GMAccount").properties.append .CreateProperty("Size",dbtext,25)

datdatbase.Tabledefs.append tdfnewRecords
End if
End with

Any suggestions?

 >> Stay informed about: Need to change A Field Size 
Back to top
Login to vote
Douglas J. Steele

External


Since: Mar 14, 2004
Posts: 1626



(Msg. 2) Posted: Sat Feb 07, 2004 10:18 am
Post subject: Re: Need to change A Field Size [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Once the Field's been added to the TableDef, its size property is read-only.

What you need to do is:

1) Add a new field of the correct size.
2) Run an Update query to populate the new field with the existing data
3) Delete the old field
4) Rename the new field to the old field's name
5) Compact the database

This is essentially what Access does behind the scenes if you make such a
change through the GUI (other than the compacting part...)

--
Doug Steele, Microsoft Access MVP
<a style='text-decoration: underline;' href="http://I.Am/DougSteele" target="_blank">http://I.Am/DougSteele</a>
(No private e-mails, please)



"Michael A. Gunther" <guntherm RemoveThis @chuckals.net> wrote in message
news:mATUb.40$ek7.45556@news.uswest.net...
 > I am using DAO. and a field was created and is incorrect in size, was
 > created at 20 char's and I need it to be 25 chars.
 >
 > Dim tbfNewRecords as DAO.tabledef
 > Dim Size as Property
 >
 > Set tbfNewRecords = datdatabase.tabledefs("New Records")
 >
 >
 > With tbfNewRecords
 >
 > If .fields("GMAccount").fieldsize = 20 then
 > .fields("GMAccount").properties.append
..CreateProperty("Size",dbtext,25)
 >
 > datdatbase.Tabledefs.append tdfnewRecords
 > End if
 > End with
 >
 > Any suggestions?
 >
 >
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Need to change A Field Size 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Test for empty field in a DAO Recordset - Can anyone help me to determine when an integer field contains nothing? It seems to be different than a null variable and I can't remember how to do this simple thing. I'm using a DAO 3.6 Recordset If the Integer field [IDNumber] is blank or empty I..

DAO 3.6 record locking - Hi, Is it possible to programmatically lock a single record in a VB application using DAO 3.6? I would like to lock users' records when they log on to the app. Later I can check if a user's record is locked to see if they are logged in or not. (I....

Fixes for VB4 or DAO 3.0 - I've got VB4 (32-bit) and it seems to use DAO 3.0. Is there a service pack for either of these that I can use? I'm having issues with DAO and > 2GB of RAM on the machine, and don't want to have to move to a newer version of VB if I can help it, just t...

Jet error - I've just started getting this error message on a seemingly random basis. 'The Microsoft Jet database engine does not recognize 'CID' as a valid field name or expression.' CID is a text field, and it is a valid column name. The line of code that..

DAO reference / Access 2007 - while using an Access 2007 .accdb file I can access the dao. object very easily. the following code in VBA works well : Function getrecordcount(strTableName As String) As Long Dim dbCurrent As DAO.Database Set db = CurrentDb Dim rstRecords A...
   Database Help (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]