• Change Data Type (2000)

    Author
    Topic
    #408431

    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

    Viewing 0 reply threads
    Author
    Replies
    • #862247

      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.

    Viewing 0 reply threads
    Reply To: Change Data Type (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: