Results 1 to 6 of 6
  1. #1
    Grooz13 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    97

    return 0 instead of #error when dividing by 0

    Ok i have this Calculated field in a query



    Dollars$ : Profit/Sold_Price

    and if often return me 0 since sometime we don't charge for some minor things and I would like to return 0 instead of #error... I tried various things but didn't get any results... any idea ?

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Dollars$: Iif([Sold_Price]=0,0,[Profit]/[Sold_Price])*1

    Cheers,

  3. #3
    Grooz13 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    97
    doesn't work it always tell me invalid number and point me to the 0,0

  4. #4
    Grooz13 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    97
    it might be important to note that the Profit is also a calculated field...

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Grooz13 View Post
    it might be important to note that the Profit is also a calculated field...
    post your query SQL please

  6. #6
    Grooz13 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    97
    Sorry my Name are in french...
    but the 3 fields that I need are in bold and the first is the 1st calculated field and the second is another calculated field that return me #Error instead of 0 and the Iff isn't there since I hade problem with it, query wouldn't work with it

    again sorry for the french

    those are the 2 that cause a problem
    Revient_Prevu = Profit
    Prix_de_vente = Price_Sold
    [Prix_de_Vente]-[Coût_Stock]-[Coût_Commandes]-[Coût_Mod]-[Coût_Commission] AS Revient_Prevu, ([Revient_Prevu]/[Prix_de_vente]) AS Profit_Prévu
    Code:
     
    SELECT Tbl_Soumission.No_Job_auto, Tbl_Soumission.No_Job, Tbl_Soumission.No_Client, Tbl_Soumission.Nom_Job, Tbl_Soumission.No_Type, Tbl_Soumission.No_Peinture, Tbl_Soumission.Cause, Tbl_Soumission.Prix_de_vente, Tbl_Production.Date_Produite, Tbl_Commande.Coût_Stock, Tbl_Commande.Coût_Commande, Tbl_Client.[Commission%], Tbl_Commande.Temps_Ebenisterie AS TE, Tbl_Commande.Temps_Ligne AS TL, Tbl_Commande.Temps_Peinture AS TP, Tbl_Commande.Temps_Ligne_Couleur AS TLC, Val([Temps_Ebenisterie])+Val([Temps_Ligne])+Val([Temps_Peinture])+Val([Temps_Ligne_Couleur]) AS Temps_Prévus, [Prix_de_Vente]-[Coût_Stock]-[Coût_Commandes]-[Coût_Mod]-[Coût_Commission] AS Revient_Prevu, ([Revient_Prevu]/[Prix_de_vente]) AS Profit_Prévu, [Coût_Commande]-[Coût_Stock] AS Coût_Commandes, ([Commission%]*[Prix_de_Vente])/100 AS Coût_Commission, [Temps_Prévus]*60 AS Coût_MOD, Tbl_Soumission.Job_Confirmee, Tbl_Soumission.No_Etat
    FROM (Tbl_Client INNER JOIN Tbl_Soumission ON Tbl_Client.No_Client = Tbl_Soumission.No_Client) INNER JOIN (Tbl_Production INNER JOIN Tbl_Commande ON Tbl_Production.No_Soumission_Auto = Tbl_Commande.No_Soumission_Auto) ON Tbl_Soumission.No_Job_auto = Tbl_Commande.No_Soumission_Auto
    WHERE (((Tbl_Soumission.Job_Confirmee) Is Not Null) AND ((Tbl_Soumission.No_Etat)=6 Or (Tbl_Soumission.No_Etat)=7 Or (Tbl_Soumission.No_Etat)=12));

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

Similar Threads

  1. Specify return value
    By Desstro in forum Queries
    Replies: 2
    Last Post: 06-19-2010, 02:12 AM
  2. Dividing a number stored as text
    By Mclaren in forum Programming
    Replies: 1
    Last Post: 05-04-2010, 07:50 AM
  3. Help dividing two fields in a query
    By aronnov in forum Access
    Replies: 2
    Last Post: 04-29-2010, 12:34 PM
  4. Tax Return Application
    By Hobbledehoy in forum Access
    Replies: 1
    Last Post: 04-18-2010, 05:41 AM
  5. Return value of row above
    By marimar1097 in forum Access
    Replies: 7
    Last Post: 10-20-2009, 08:06 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