Link to home
Start Free TrialLog in
Avatar of emcullen
emcullen

asked on

Change Access field type from number to text in VBA.

I have imported an excel file into access.  One field is being read as numeric if the user entered only numbers into that column, but in fact in the Access application it is a text field.  When I try to join the imported table field (imported as "number") to the related field ("Text") it of course does not work.  How can I programatically change the field type from number to text after I import the table and before I need to join it to related tables?  Thank you!
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Another thought here.. most established developers will import Excel data into Access into a 'temporary' table with all text fields.  (I usually prefix these with timp_)
That way, all data makes it into Access without any data conversion errors.

Then, you can run a bunch of SELECT / UPDATE queries to 'scrub' your data, making sure dates are dates, numbers are numbers, etc.
Then when you're satisfied your data is good, INSERT into your ultimate destination table(s), then delete all from the temp table.

Hope this helps.
-Jim