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

VBA Change data type

Status
Not open for further replies.

sap1958

Technical User
Oct 22, 2009
138
US
I have loaded 80 excel files in access. I have 3 fields as follows:
Client_Code
Medical_Code
Duration_Code

In some cases the table fields are correctly formatted as text fields. In several cases the fields are marked as number data type. The name of the files are in sequence and called inv1, inv2 inv3 etc...

Is there a way to have a vba module that
1. checks for datatype of text for the 3 fields I have mentioned and skips to the next if they are a text
2. If any of the fields are a number data type, change that field to a text data type

The script should loop from the first records to the last and check the fields.
 



Hi,

Fix the data in the source workbooks first and then import.
Code:
dim r as range

for each r in yourrangeofids
  with r
    if isnumeric(.value) then .value = "'" & .value
  end with
next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top