Results 1 to 4 of 4
  1. #1
    CindyR19 is offline Novice
    Windows 2K Access 2003
    Join Date
    Aug 2011
    Posts
    9

    Convert Number to String in .csv extract

    Hi,

    I have this


    Private Sub Command22_Click()
    ExportText "TestExtract_CM", "C:\Documents and Settings\martinc\Desktop\TestingExport.csv", "10,HO018000," & Format(Date, "yyyymmdd") & "," & Format(Time, "HHMMSS") & "," & " ," & Str("09444"), "TestExportSpec"

    End Sub

    But the red text when I open the extract is 9444, it's dropping the zero. How can I change that? I also tried CStr and it did not work.

    Thanks.

  2. #2
    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
    THe argument for the Str() function is a number, not a string. In this case I have to ask, why not just use "09444" instead of using the function?

  3. #3
    CindyR19 is offline Novice
    Windows 2K Access 2003
    Join Date
    Aug 2011
    Posts
    9
    I tried it without the " ", but it automatically gets changed to 9444. I also tried just "0944", but when I open the .csv it is displayed as 9444.

    Correction: it drops the leading zero when opened with Excel, it does not drop it when it's opened with notepad.

  4. #4
    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
    AhhHaa! You can see you are fighting with the fact that leading zeros mean nothing in a number. Try wraping it in single quotes as well. "'0944'"

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

Similar Threads

  1. Replies: 2
    Last Post: 04-07-2011, 10:15 AM
  2. Convert auto number
    By JonB1 in forum Access
    Replies: 2
    Last Post: 02-20-2011, 10:26 PM
  3. Number convert to date
    By Argus in forum Programming
    Replies: 1
    Last Post: 08-05-2009, 02:21 PM
  4. Convert string to date
    By ~SwAmPdOnKeY~ in forum Queries
    Replies: 4
    Last Post: 09-11-2008, 07:19 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06:55 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