• Is Null (Access 2000)

    Author
    Topic
    #358486

    I have a function that substracts the quantity in the stock in the field called stock in the table Products.It works fine,however i do not want to substract if the stock is Null, and give a message ”
    there are no more goods available”.How can i confine the function only if the stock is not Null ?

    The function is the following

    strSQLBulems = “UPDATE Products SET Stock = Stock – ” & Me.cartons & ” WHERE ProductID=” & Me.Productid

    Viewing 0 reply threads
    Author
    Replies
    • #535043

      Your stock should *never* be null because that doesn’t make sense. The least value it should have is zero. Logically it’s impossible to have null anything.

      • #535044

        Thank you very much indeed for your reply.If i subtract with 0 quantities, then i receice minus values.How can i avoid that?I want to substract only when the quantity is not 0

        Best regards

        • #535050

          you need to do the calculation first, and test the result with an if-then-else statement of the form
          if result >= 0 then
          ‘ positive result processing
          else
          ‘ negative result processing
          end if

        • #535056

          Try something like this:

          If lngStock >0 And _
                  lngStock>=Me.Cartons Then
             lngNewStock = lngStock - Me.Cartons
          Else
            lngNewStock = 0
          End If

          I don’t see how you can subtract more items than you have in inventory unless your inventory records aren’t being kept current. You shouldn’t be able to remove more cartons from inventory than exist there, so you shouldn’t be coming up with negative numbers.

    Viewing 0 reply threads
    Reply To: Is Null (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: