Results 1 to 2 of 2
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    Formatting Issue


    I am copying data from an excel sheet to an access table. The format I want for a column is "000".
    Although the column in the excel sheet shows data being in the format "000", when importing data to access table via transferspreadsheet method,
    it deletes the leading zeros in the column. For example if the actual data in the excel column is say "001", it ends up in the access table after import as just "1".

    Actually, I am doing some manipulation in the excel sheet coz the data for this excel column actually comes from a different column.
    For example, in the expression "0002-001", "001" is the text I want for my column in the access table.

    I am separating the text "0002-001" using the following method:

    First formatting the destination column to text (or general) like this,
    .Range("N2:N2999").Select
    .Selection.NumberFormat = "000"

    And then using the method,

    .Selection.TextToColumns Destination:=Range("M2:N2"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
    :="-", FieldInfo:=Array(Array(2, 2), Array(2, 1)), TrailingMinusNumbers:=False

    Can somebody point out what am I doing wrong?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This worked for me. The TransferSpreadsheet import retained the leading zeros.

    Sheet1.Range("C1:C4").NumberFormat = "000"
    Sheet1.Range("A1:A4").TextToColumns Destination:=Range("B1:C4"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
    :="-", FieldInfo:=Array(Array(2, 2), Array(2, 1)), TrailingMinusNumbers:=False

    Can't replicate your issue. If you want to provide Excel file for analysis, attach to post.
    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. Conditional Formatting vs. VBA Formatting
    By gopherking in forum Reports
    Replies: 5
    Last Post: 11-09-2011, 06:53 PM
  2. Issue with formatting field from subquery
    By eww in forum Programming
    Replies: 1
    Last Post: 08-30-2011, 10:46 AM
  3. Between formatting
    By reidn in forum Queries
    Replies: 2
    Last Post: 07-21-2011, 12:11 PM
  4. zip code formatting
    By techexpressinc in forum Queries
    Replies: 14
    Last Post: 09-21-2010, 06:03 AM
  5. Formatting a date
    By NISMOJim in forum Queries
    Replies: 7
    Last Post: 09-17-2010, 05:44 PM

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