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

    Complicated function (Access 2000)

    I have a very complicated problem.At first i didnt want to bother the Forum
    but i am spending already 2 days without any success and my last hope
    is with the Forum.
    I have ALWAYS received solutions to my problems in this Forum.But i will be specially grateful if somebody succeeds to solve this special problem.


    I have a function that checks whether the cartons in the warehouse,which
    are branch0, are greater than the cartons ordered.
    Which means that
    If branch < cartons then
    exit function

    The function works great if the cartons are not opened.But when one carton is opened, and one piece from the carton is sold, then the number of the cartons in the warehouse is with 1 less, since one carton
    is opened.The fault in my function is that it allows to order a non existing carton.
    For example
    If one cartons contains 24 pieces then it is o.k. The pieces are obtained by
    multiplying cartons*pack = pieces.
    If however we have sold one piece, then the carton will not be full,but the function
    does not recognize it.
    The part of the function that works in this way is the folowing:

    If CLng(DLookup("branch", "Products", strCondition)) < CLng(cartons) Then
    MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
    DoCmd.GoToControl "productid"
    Exit Function
    End If
    Else
    .................

    In order to solve my problem, I have tried to enter a new variable TrueCartons,by multiplying the cartons with the pack and dividing to the pack. And then,if the true cartons are less than the real cartons, the Exit Function.

    TrueCartons = (CLng(DLookup("branch0", "Products", strCondition)) * CLng(pack)) / [pack]

    If TrueCartons < CLng(DLookup("branch0", "Products", strCondition)) Then

    MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
    Exit function

    To my regret nothing happens and no message appears.
    Where the fault may lie ?

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Complicated function (Access 2000)

    Have you tried stepping thru (Debug F8) and see what the values are ?

    Perhaps it would be better to contain the value first and then act upon the value with the msgbox after !

    """ AirCode"""""

    Me!txtUnBound = CLng(DLookup("branch", "Products", strCondition)) < CLng(cartons).Value
    If Me!txtUnBound < CLng(cartons) Then
    MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
    DoCmd.GoToControl "productid"
    Exit Function
    End If
    Else

Posting Permissions

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