Results 1 to 8 of 8
  1. #1
    anasttin is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    37

    Converting text to numbers and losing all negative values. Please help.

    Hi,




    I've set up a database and in one of the fields in my table the numbers are stored as text and negative numbers have a "-" character preceeding them. When I change the field
    data type from text to numbers, I lose the negative values from my output.



    ie. in my code below, negative numbers are not being picked up by the select statement - only positive numbers are being captured.




    -------------------------------------------------------
    SELECT val(nz([db].[value])) as myamount,
    from [db]
    -------------------------------------------------------



    Thanks in advance for any help you can offer.


    Kim

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I cannot replicate the issue. Conversion works fine.

    Value is a reserved word. Should not use reserved words as names, however, that is not cause of your issue.

    Why is data not stored as number?
    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
    anasttin is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    37

    thanks

    Thanks for the reply.

    Using "Value" was just as an example and not in my real code.

    Numbers are not stored as numbers because they come into Access via a linked table to Excel and the first 6 rows in Excel are text so Access interprets all the column contents as text even though all the real numeric data is below.

    Can you suggest a work around to fix my problem, otherwise I'm in a real bind?

    Thanks so much June7

    Kim



    Quote Originally Posted by June7 View Post
    I cannot replicate the issue. Conversion works fine.

    Value is a reserved word. Should not use reserved words as names, however, that is not cause of your issue.

    Why is data not stored as number?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Hard to do since I cannot replicate the issue and never heard of it. If you want to provide db for analysis, follow instructions at bottom of my post.

    Do you really have a comma before the FROM in your SQL statement? That should cause an error.
    Last edited by June7; 05-15-2017 at 11:51 AM.
    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
    anasttin is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    37

    thank you so much

    Hi June7 and thanks again for taking an interest. Your support is super appreciated.

    I've attached a zip file with an extract of the database and the Excel file the database is linking to. Both have been manipulated to remove confidential data as you mention.

    As you can see, there are negative numbers in the excel file that the query just does not pick up. If you can assist to find the problem it will save me heaps of time.

    Many thanks,

    Kim


    Quote Originally Posted by June7 View Post
    Hard to do since I cannot replicate the issue and never heard of it. If you want to provide db for analysis, follow instructions at bottom of my post.

    Do you really have a common before the FROM in your SQL statement? That should cause an error.
    Attached Files Attached Files

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Use 'format cells' to change desired columns to numbers in the spreadsheet.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Here is something weird. When I have the spreadsheet open, the link and the query show negative sign. When the spreadsheet is closed they show () for negatives. The spreadsheet is formatted to show () for negative values.

    I did a test and formatted one spreadsheet column as Number and to display - instead of () for negative. Now I get negative sign for that field in the link and query even when spreadsheet is closed.
    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.

  8. #8
    anasttin is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    37

    Thank you!!!

    Hi June7 and thanks so much for your ongoing help. I've decided to just change the format of my source data and it appears to resolve the problem.

    A very simple fix at the end of the day.

    Truly appreciate your help.

    Kim




    Quote Originally Posted by June7 View Post
    Here is something weird. When I have the spreadsheet open, the link and the query show negative sign. When the spreadsheet is closed they show () for negatives. The spreadsheet is formatted to show () for negative values.

    I did a test and formatted one spreadsheet column as Number and to display - instead of () for negative. Now I get negative sign for that field in the link and query even when spreadsheet is closed.

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

Similar Threads

  1. need help with formatting negative numbers
    By orientalmed in forum Access
    Replies: 3
    Last Post: 03-06-2013, 01:24 PM
  2. Converting negative number to positive using QBE??
    By shabbaranks in forum Queries
    Replies: 5
    Last Post: 03-23-2012, 08:57 AM
  3. Sum Negative Numbers In Colum
    By geraldselectric in forum Access
    Replies: 1
    Last Post: 01-16-2012, 03:42 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 Positive to Negative
    By TheProfessorIII in forum Access
    Replies: 5
    Last Post: 03-22-2011, 06:38 AM

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