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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prgorammatically Alter column Datatype...? 1

Status
Not open for further replies.
Oct 13, 2004
39
US
Anyone have any ideas how to create a function that would change the datatype of a table field??

I have data that is imported to access so it is put in as text and I am hoping to run a macro to convert the text field to a DATE field so that a report can properly calculate things.

was thinking something like this...

ALTER TABLE tblData
MODIFY (columnname VARCHAR2(10));

...but anyone know how to do that in access?

Thanks in advance for any insight!!!!!!!!!

rock on!
 
Programmatically..

How brilliant. you cant edit your own posts?!?!?!?!?!?!?!?!?
 
DoCmd.RunSQL "ALTER TABLE tblData ALTER COLUMN columnname DateTime"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV!

this was what i ended up with and works great
Code:
Function convertToDate()

    Dim strTableName As String
    Dim strColumnName As String
    Dim strSQL As String
    
    strTableName = InputBox("Enter the name of the table", "Enter Table")
    strColumnName = InputBox("Enter the name of the column to convert", "Enter Column")
    DoCmd.RunSQL "ALTER TABLE [" & strTableName & "] ALTER COLUMN [" & strColumnName & "] DateTime;"
    
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top