Results 1 to 5 of 5
  1. #1
    uaguy3005 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2010
    Posts
    45

    Number Format

    I'm having trouble with a calculated value coming up as text instead of a number. I've tried addressing it with the format function, but still no luck. Any ideas on what I can do to get this PPM field to be recognized as a number?



    SELECT IIf(Eval(Hour([InspectDateTime]) Between 0 And 6),DateValue([InspectDateTime])-1,DateValue([InspectDateTime])) AS SortDate, tblParts.PartNum, Sum(tblSortData.QtyInspected) AS SumOfQtyInspected, Sum(Nz([TotRej],0)) AS QtyRejected, Format(([QtyRejected]/[SumOfQtyInspected])*1000000,0) AS PPM
    FROM tblParts INNER JOIN (tblSortData LEFT JOIN (SELECT tblRejects.SortDataID, Sum(tblRejects.QtyRejected) AS TotRej FROM tblRejects GROUP BY tblRejects.SortDataID) AS qzTotRej ON tblSortData.SortDataID = qzTotRej.SortDataID) ON tblParts.PartID = tblSortData.PartsID
    GROUP BY IIf(Eval(Hour([InspectDateTime]) Between 0 And 6),DateValue([InspectDateTime])-1,DateValue([InspectDateTime])), tblParts.PartNum
    ORDER BY IIf(Eval(Hour([InspectDateTime]) Between 0 And 6),DateValue([InspectDateTime])-1,DateValue([InspectDateTime]));

    Database attached. The query I'm having the problem with is qryTPP. Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Format() and FormatNumber() functions return text, not true dates or numbers.

    If you need date or number then use appropriate conversion functions: CDate, CInt, CDbl, Val, DateValue. They will error on Null.

    Which calculation is issue?
    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
    uaguy3005 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2010
    Posts
    45
    Quote Originally Posted by June7 View Post
    Format() and FormatNumber() functions return text, not true dates or numbers.

    If you need date or number then use appropriate conversion functions: CDate, CInt, CDbl, Val, DateValue. They will error on Null.

    Which calculation is issue?
    Issue was with the Format(([QtyRejected]/[SumOfQtyInspected])*1000000,0) AS PPM, but that seemed to fix it. How do you set it to round the decimal portion? The CInt, returns a #Num! error.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Do you really need to format and round in query? Maybe instead use form/report textbox Format property.
    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
    uaguy3005 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2010
    Posts
    45
    Quote Originally Posted by June7 View Post
    Do you really need to format and round in query? Maybe instead use form/report textbox Format property.
    Good point. Thanks for help!

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

Similar Threads

  1. SQL Number format
    By yagerlegi in forum Forms
    Replies: 1
    Last Post: 12-16-2014, 06:17 PM
  2. Number Format to General Format
    By mkc80 in forum Access
    Replies: 2
    Last Post: 05-05-2012, 02:10 AM
  3. Number Field Format.
    By cap.zadi in forum Reports
    Replies: 2
    Last Post: 12-04-2011, 10:17 PM
  4. Number format in queries
    By bullwinkle55423 in forum Queries
    Replies: 1
    Last Post: 08-16-2011, 06:55 PM
  5. Phone number format
    By ManvinderKaur in forum Access
    Replies: 1
    Last Post: 06-24-2010, 08:07 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