changing data type when importing Excel worksheet
Hello all! I am importing a worksheet from Excel and one of the fields Imports as a number. Since I do not perform any arithmetic on this field, I want it to be a text field (also in case they begin to add letters to this field). Is there anyway I can change the field type during the import procedure or do I have to do it afterwards? Here is my code for the import.
Public Function ImportFileVersion() As Boolean
Dim strPath As String
Dim strSQl As String
'Set the path
strPath = "S:\MIS\admin\MidAtl_Hierarchy_2004.xls"
strSQl = "DELETE * FROM tblHierarchy"
'If table exist, delete and update with latest version
'If table does not exist, continue
On Error Resume Next
DoCmd.SetWarnings False
DoCmd.RunSQL strSQl
DoCmd.SetWarnings True
'Import the data only in this range from Excel
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"tblHierarchy", strPath, True, "A1:H423"
'Open the table
DoCmd.OpenTable "tblHierarchy", acViewNormal
ImportFileVersion = True
End Function
Also if you see how my code can be more efficient, please feel free to chop it up.
Thanks in advance!
|