Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is Null (Access 2000)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Is Null (Access 2000)

    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.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is Null (Access 2000)

    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

  4. #4
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is Null (Access 2000)

    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

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Is Null (Access 2000)

    Try something like this:

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

    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.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •