validation macro with If statement not working

rsmhawaii

New member
Local time
Today, 07:46
Joined
Mar 11, 2004
Messages
4
I created a macro with an "If" statement using expression builder and it doesn't work and I don't receive an error.

If ([Forms]![Inventory_OutboundRequest]![SF_inventorydetailsitems].[Form]![QtyAdjustOut])> Forms![Inventory_OutboundRequest]![OnHand] Then
MessageBox
Message Insufficient inventory, please adjust your quantity
Beep No
Type Warning!
Title Inventory check

I set the property sheet value of [QtyAdjustOut] to run the macro "After Update". So far no luck. Any help is greatly appreciated...running out of hair :)
 
Try this


Code:
=IIf([SF_inventorydetailsitems].[Form]![QtyAdjustOut]>[OnHand],MsgBox("Message Insufficient inventory, please adjust your quantity",0,"Title Inventory check"))
 
Hi deanamiles86,

Thanks for the suggestion. I get the following:

The expression After Update you entered as the event property setting produced the following error: The object doesn't contain the Automation object 'SF_inventorydetailsitems.

The expression may not result in teh name of a macro, the name of a user-defiend fuction or [Event Procedure].
 
Not sure why this hasn't worked, I have created a replica DB and it worked

Am I right in thinking

You are using form Inventory_OutboundRequest and You are using the field OnHand

And within the same form you are using a sub form called SF_inventorydetailsitems with the field QtyAdjustOut
 
yes, you are correct. I can't seem to figure it out either. The logic is correct.
 
i cant see why you are getting this error, have you got any other events happening in this form?
 
do it in Before Update:

If ([Forms]![Inventory_OutboundRequest]![SF_inventorydetailsitems].[Form]![QtyAdjustOut])> Forms![Inventory_OutboundRequest]![OnHand] Then
MessageBox
Message Insufficient inventory, please adjust your quantity
Beep No
Type Warning!
Title Inventory check

CancelEvent
 
ive now been able to recreate this error and i fixed it with the following

Code:
=IIf([QtyAdjustOut]>[Forms]![Inventory_OutboundRequest]![OnHand],MsgBox("Message Insufficient inventory, please adjust your quantity",0,"Title Inventory check"))
 

Users who are viewing this thread

Back
Top Bottom