Use VB to import Excel numbers as text

wsteinbe

Board Regular
Joined
Feb 16, 2006
Messages
58
I have a vba script that pulls in an excel file:

Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, tab_Union & "Extra", "C:\Local\union\in\" & tab_Union & "_Extra", True

This spreadsheet has a column of numbers, but they are joining a text field in the database (because rarely there are 1 or 2 fields that are text). This is importing as numbers and I get a type mismatch in join.

I either want a way to import the field as a number or change the field type to a number after it is imported, using SQL or VBA without altering the excel spreadsheet.

Much thanks!
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,931
Office Version
  1. 365
Platform
  1. Windows
Why not import into an existing table where that field's data type is Text?
 

Watch MrExcel Video

Forum statistics

Threads
1,114,403
Messages
5,547,750
Members
410,811
Latest member
adustin42
Top