By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,604 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,604 IT Pros & Developers. It's quick & easy.

Change Ms-Access Field data type thru VB.Net

P: 5
Hi All,

I am using VB.Net 2003 and Ms-Access 2003. I want to change the data type of fileds programmatically. I could not find any method in to do this.

i) I tried using the sql query "ALTER TABLE TableName ALTER COLUMN FieldName Number" It works for data type like 'Number', 'Memo' etc. But if I want to change to 'Long Integer' (sub type of Number), it does not work.

ii) I tried using ADOX as shown below. It shows the 'Operation is not allowed in this context' error on "adox.Tables(TableName).Columns(FieldName).Typ e = NewType"

Dim conn As ADODB.Connection
conn = CreateObject("ADODB.Connection")
Dim adox As ADOX.Catalog
adox = CreateObject("ADOX.Catalog")
adox.ActiveConnection = conn
adox.Tables(TableName).Columns(FieldName).Type = NewType)

What am I doing wrong here? Is there any better way to do this? Please somebody help me as this is to be done urgently.

Apr 13 '07 #1
Share this Question
Share on Google+
2 Replies

P: 41
Alter Table goes thru the SQL layer which is not fully supported. This may or may help you but is worth the shot. In access turn on the macro recording, then change the type and stop the recording. Now "edit" the macro and you'll see how access needs it or it will give you a hint on how to proceed It saved me a couple of times since sometimes , or should I say lots ;-) , they do funny stuff.

Apr 14 '07 #2

P: 5
Thanks for your reply.
But I am not sure, how can we record macros in MS-Access (2003). Can you please let me know how can we do this. The following url says, it is not possible.

Apr 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.