Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change Field Size through VB

Posted on 2002-07-01
7
Medium Priority
?
215 Views
Last Modified: 2010-05-02
Can I increase the size of a Text data type Field in table (MS Access Database)?

e.g. Table Name is EMPLOYEE
    Field Name is Fname Text(20)

Through VB Code I want to make it 25 or greater.

how it is possible? pl. let me know.

0
Comment
Question by:hnd_ra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7122507
Hi hnd_ra,

don't think it's possible. see what MSDN help says

ALTER TABLE table {ADD {COLUMN field type[(size)] [NOT NULL] [CONSTRAINT index] |
CONSTRAINT multifieldindex} |
DROP {COLUMN field I CONSTRAINT indexname} }

Using the ALTER TABLE statement, you can alter an existing table in several ways. You can:

Use ADD COLUMN to add a new field to the table.

Use ADD CONSTRAINT to add a multiple-field index.

Use DROP COLUMN to delete a field.

Use DROP CONSTRAINT to delete a multiple-field index.

if you still want to do it there's a small workaround through DAO

-Assume a field trans_type TEXT (20) whose size needs to be 30.
-Add a field trans_type_temp TEXT(30)
-UPDATE <Table> SET trans_type_temp = trans_type
-Delete the trans_type field.
-Add a field trans_type TEXT(30)
-UPDATE <Table> SET trans_type = trans_type_temp
-Delete the trans_type_temp field.

lot of work better make a new table and move the data

HAGD:O)Bruintje
0
 
LVL 4

Expert Comment

by:RichW
ID: 7122595
Dim cnn as ADODB.Connection
Set cnn = New ADODB.Connection
   With cnn
      .Provider = "Microsoft.Jet.OLEDB.4.0;"
      .Open "Data Source=C:\Path\YourDB.mdb;"
   End With

cnn.Execute "ALTER TABLE YOURTABLE ALTER [FName] VarChar(25)"

0
 
LVL 4

Accepted Solution

by:
RichW earned 80 total points
ID: 7122639
bruintje,

Sorry.  I started writing the comment, then walked away and came back.  Didn't know you already gave the same thing I entered.

Anyway, hnd_ra the line should read:

cnn.Execute "ALTER TABLE EMPLOYEE ALTER [FName] VarChar(25)"

Cheers,
RichW
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:bruintje
ID: 7122655
no problem, just wondering why i didn't do it with ado, guess because i got no setup to test now ;)
0
 

Author Comment

by:hnd_ra
ID: 7122894
Thanks  RichW ,
   This is working fine.
I wnted to know ne more thing, if I have to chnage DatType e.g. from Text to Long, then what will be the syntex.

Pl. let me know.

Again a lot of thanks

0
 
LVL 4

Expert Comment

by:RichW
ID: 7122931
Thanks hnd_ra.

I believe the following will change it to Number (Long Integer) for Access:

cnn.Execute "ALTER TABLE EMPLOYEE ALTER [FName] Long "

Thanks again!
RichW
0
 

Author Comment

by:hnd_ra
ID: 7123002
Thanks RichW ,
     Yeahn its working fine. Actually earlier I also did like this one but by mistake there was a parenthesis ")" in my syntex.

Really u r great.........

Thanks a lot

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question