Type Conversion Failure!!!!

Discussion in 'Access Conversion' started by gregperry, Mar 13, 2010.

  1. gregperry

    gregperry Guest

    I am trying to import a .csv text file into access using an import

    specification and everytime I try to import the data I get a type

    conversion failure because there is no percentage data type that will

    recognize the values that are in the .csv file.

    Does anyone know how I can accomplish this import? I am really

    wanting to automate this import process somehow using VBA and need to

    first get this data in the table.


    Any help would be greatly appreciated!!!

    Thanks in advance,

    Greg
     
    gregperry, Mar 13, 2010
    #1
    1. Advertisements

  2. gregperry

    gregperry Guest

    The data field that I am trying to import that is causing the problems has
    percent data in it.
     
    gregperry, Mar 13, 2010
    #2
    1. Advertisements

  3. gregperry

    Bob Howard Guest

    I import .csv text files into my application. There's nothing special I do
    about any of the data elements. After reading each input record, I simply
    parse it into a Variant array. I then deal with each element, one at a
    time.

    It would seem that if a specific element (Variant by that time) is a
    percentage, you would deal with it accordingly. The fact that it came from
    a .csv text file is no longer a material matter.

    bob
     
    Bob Howard, Mar 14, 2010
    #3
  4. gregperry

    skarlet Guest

    i can help you
     
    skarlet, Mar 24, 2010
    #4
  5. gregperry

    celeste Guest

     
    celeste, Mar 25, 2010
    #5
  6. My question is how can I deal with it accordingly when there is no percentage
    data type for an access import spec? It automatically converst the
    percentage to a string.

     
    gregperry via AccessMonster.com, Mar 25, 2010
    #6
  7. Thank you for your reply. I am still at a loss with this particular issue.
    I ended up just importing the value as a string and using the left & right
    string functions to pull the percentage sign off and recalculate the string
    as a percentage. Which works fine I guess, I was just wondering if there
    wasn't a more effective way to handle this.
     
    gregperry via AccessMonster.com, Mar 25, 2010
    #7
  8. gregperry

    vincent Guest

    In my opinion, you should first remove all '%' signes in your .csv file by
    opening the file and reading line by line using something like
    'replace(line1,'%','')' which will replace all % sign by an empty string.
    Then check if the decimal sign is correct according to your settings (some
    may need a '.' other a ',').
    Percentages are just number with some decimals, so you should consider them
    as numbers.

    Good luck
    Vincent
     
    vincent, Mar 28, 2010
    #8
  9. gregperry

    vincent Guest

    Make sure no '%' sign is present in your csv file. If there are, use code to
    open the file line by line and replace all % sign with '' (=null string)
    using Replace(linx,'%','') or open the file manually and use the function
    'Replace' to do the same.
    Also make sure that the decimal sign is correct in your csv file: try with a
    comma ',' or a dot '.' but it must be recognized as a decimal sign when
    importing.

    Percentages are just numbers with 2 (or more) decimals. After importing in
    Access you can format the display with 2 or more decimals.

    Good luck.
    Vincent
     
    vincent, Mar 29, 2010
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.