Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHANGING ACCESS TABLE PROPERTIES WITH VB

Status
Not open for further replies.

TOMRx

Programmer
Jul 16, 2000
12
0
0
US
I need to change the length of a field already in use in a table in an Access database. The field is indexed so I cannot delete the field & re-create it in VB without errors.

I can delete the table completely, but I am wondering if there is a way to copy the structure of a table in one database to create or modify a table in another database using VB code.

Any suggestions??
 
You can do this by executing a single SQL statement using any of the Data Access methods (ADO is recommended)

Suppose that you want to change the lenght of FirstName field in Employees table to 30 characters. To do so, execute a command on a connection opened to the database with this CommandText:

ALTER TABLE Employees ALTER COLUMN FirstName TEXT(30)

 
I am using VB5 and I get a syntax error in
db.EXECUTE "ALTER TABLE Employees ALTER COLUMN FirstName TEXT(30);"

error says syntax error in ALTER TABLE statement.

it appears that the ALTER COLUMN is the offending part???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top