Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change Data Type (2000)

    I have a routine which imports a file from Excel and create a new table. All of the data is firstly imported as text so that I can process some of the information. I then wish to change the data type of one of the fields in the imported table from text to number (double). I there a method of doing this?
    John

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Change Data Type (2000)

    I presume you mean you want to change the field type in code. There is a method for doing this using DAO - you basically open the TableDef collection and then modify the Fields collection of the specific TableDef that your table was imported into. There are some inherent risks in doing that if your file coming in from Excel contains alpha data in the field you are converting to Double - so managing the errors issues will get to be important.

    There are a couple of other strategies as well. You might consider copying the data from the import table to a different table with the field type already set to Double, or you could simply import the table into a pre-existing table with the Double field type. The latter is attractive because when you encounter errors, the import process creates an Import Errors table which describes the problem with the data, and the row in which it occurred.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •