446,392 Members | 1,576 Online
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

# Complicated problem

 P: n/a I have a very complicated 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 ? Nov 12 '05 #1