Results 1 to 8 of 8
  1. #1
    fpmsi is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    16

    Type Conversion Failure

    I have a excel file that is being imported (appended) to a already created table monthly. I am receiving the "Type Conversion Failure" in the Zip Code field.



    All zip codes are being imported except for a few with the following data examples:
    OX135dJ
    01730-1846

    The zipcode field in the table is set as just "text".


    Any help would be appreciated. thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I just tested importing the sample data you posted and it works. However, I did this in Access2010 but expect would have same result with Access2007. Provide your Excel file for analysis. Remove confidential data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Zip codes should really be a Text field but Access will try and import a field that starts as a number as a Double unless you make sure *all* of the column is Text in Excel.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    RuralGuy's suggestion is a possible issue. Are you using the import wizard? I just tested import where the first row of data was an all-numeric zip code and the import wizard set the field as text anyway and all records imported.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    fpmsi is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    16
    Thanks Guys - If i format the column in excel to "text" before importing it seems to work fine.

    This is being imported through a form not an import wizard so I guess now i need to see if i can control that column before import. As I am not sure that the client is going to want to have to format cells before he imports his file.

    Can Access format a column before import?

    Using a basic filelist for him to select a file and import:

    DoCmd.TransferSpreadsheet acImport, , _
    "tblMailing", FileList.Value, True, ""

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, you can use VBA to set properties of worksheet cells. Just not sure about the specific syntax. Google: vba excel set cell formt - bet you will get results. Or use the macro recorder to get some code and then clean it up.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    fpmsi is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    16
    Recorded the macro and received:

    Sub Macro1()
    Columns("H:H").Select
    Selection.NumberFormat = "@"
    End Sub

    Not sure how to use that during import from access form button. Also would need to change (H:H) to find "Zip Code" field in case it moved.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Running the code from Access involves declaring and setting an Excel app object variable and worksheet object variable. Google, there is lots out there.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. f4 combo box failure
    By djuplina in forum Access
    Replies: 2
    Last Post: 09-19-2011, 01:03 PM
  2. Date Range Failure
    By goodguy in forum Queries
    Replies: 4
    Last Post: 12-30-2010, 10:22 AM
  3. stored procedures failure
    By MrGrinch12 in forum Programming
    Replies: 1
    Last Post: 06-23-2010, 12:54 PM
  4. Data Type Conversion in Query
    By EHittner in forum Queries
    Replies: 3
    Last Post: 04-14-2010, 02:11 PM
  5. Duplicate record failure
    By bugchaser in forum Access
    Replies: 5
    Last Post: 05-21-2009, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums