Results 1 to 6 of 6
  1. #1
    sibe is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    4

    Converting Text to Single


    TT as a Text is equal
    TT= "970531101235"
    Then converted in P6 as below
    P6 = CSng(TT)
    Now P6 is equal 9.705311E+11
    Which after formatting as below;
    C6 = Format(P6, "#,####")
    It is equal 970,531,100,000
    And truncated so the last 5 digits converted to zero.
    I want to convert TT to a complete Number(970,531,101,235 : Single Percision).
    How could I solve the problem?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I tried the following

    Code:
    Sub TTEST()
        Dim TT As String: TT = "970531101235"
        Dim p6 As Single, p7 As Double
        p6 = CSng(TT)
        p7 = CDbl(TT)
        Debug.Print TT & "  " & p6 & "   " & Format(p6, "###,###,###,###,###") _
                       & "  " & p7 & "   " & Format(p7, "###,###,###,###,###")
    End Sub
    With this result:

    970531101235 9.705311E+11 970,531,100,000 970531101235 970,531,101,235


    Good luck
    Last edited by orange; 08-22-2018 at 04:19 PM. Reason: revised

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Be aware Format function returns a string, not a number. Tested in query:

    CSng("970531101235") returns number = 970531078144

    CDbl("970531101235") returns number = 970531101235

    Int() returns same as CDbl()

    VBA immediate window showed same.

    Might find these interesting:

    http://blabla.co.za/access-number-da...e-field-sizes/

    https://support.office.com/en-us/art...f-b77bae076f70
    Last edited by June7; 08-23-2018 at 02:27 PM.
    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.

  4. #4
    sibe is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    4

    Reply 01

    Quote Originally Posted by orange View Post
    I tried the following

    Code:
    Sub TTEST()
        Dim TT As String: TT = "970531101235"
        Dim p6 As Single, p7 As Double
        p6 = CSng(TT)
        p7 = CDbl(TT)
        Debug.Print TT & "  " & p6 & "   " & Format(p6, "###,###,###,###,###") _
                       & "  " & p7 & "   " & Format(p7, "###,###,###,###,###")
    End Sub
    With this result:

    970531101235 9.705311E+11 970,531,100,000 970531101235 970,531,101,235


    Good luck
    =============================
    Hi,
    Many Thanks
    Simply I used CDbl() and it solved
    I could do some summation operations after conversion
    Good luck

  5. #5
    sibe is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    4
    1234567890

  6. #6
    sibe is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    4
    Hi June7,
    Many Thanks
    Simply I used CDbl() and it solved
    I could do some summation operations after conversion
    I used Format() only for showing the conversion result.
    Anyway it is very interesting that
    "CSng("970531101235") returns number = 970531078144"
    Since it is not my present moot point, I will pay to it later.
    Good luck

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

Similar Threads

  1. Converting Text To Columns
    By gameemaster in forum Queries
    Replies: 1
    Last Post: 04-18-2017, 02:12 AM
  2. Replies: 18
    Last Post: 03-18-2016, 07:28 PM
  3. Converting a Code to Text
    By rmcafee in forum Programming
    Replies: 7
    Last Post: 09-13-2011, 08:52 PM
  4. querying and converting text to numbers
    By hollyh in forum Queries
    Replies: 2
    Last Post: 09-01-2011, 12:39 PM
  5. Converting Option value to text
    By James3mc in forum Forms
    Replies: 4
    Last Post: 11-28-2009, 11:19 PM

Tags for this Thread

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