Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then Else Statement

Status
Not open for further replies.

haj1503

Technical User
May 29, 2001
56
0
0
MY
Hi friend,

actually, i have been tried by event procedure after update something like this;

If Me.UnitsConsumed > Me.CodeNo.Column(7) Or Me.CodeNo.Column(7) = 0 Then

Else
MsgBox "Hi Friend your quantity issued exceed with quantity stock on hand, please see your superior for updating records...", vbCritical, "Materials & Procurement Management System"

Me.Undo

End If
When my colleggue update for example enter 4 pcs eventhough stock on hand is 2 then msg come up like above but the problem is when we enter 2 pcs or 1 pc the msgbox also come up like that.
would your have any idea to solve this problem?

I looking to hearing a best reply from yours.

Best regards
 
I'm not absolutely sure, but it looks like your IF..Then..Else statement is missing something - like, what to do when either condition is true. I think something like this should work:

if Me!UnitsConsumed > Me!CodeNo.Column(7) or
me!CodeNo.Column(7)= 0 then
MsgBox "Hi Friend your quantity issued exceed with quantity stock on hand, please see your superior for updating records...", vbCritical, "Materials & Procurement Management System"
Else
End if

In other words, you have your "Bad" condition" in the wrong spot. If neither condition is TRUE, then you want the process to "fall through" the "THEN.." part, and if you don't have any "else" part, it will just exit out.

IF {Something is TRUE}
THEN {DO THIS }
ELSE {Do THIS }
END IF

Jim









Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Hi Jim,

Many thanks to your replied, when I,ve read your thread I've changed my code like this :

If Me.UnitsConsumed < Me.CodeNo.Column(7) Or Me.UnitsConsumed = Me.CodeNo.Column(7) Then
MsgBox &quot;Are your want to update the quatity issued?&quot;, , &quot;Materials & Procurement Management System&quot;
DoCmd.Save
Else
MsgBox &quot;Hi Friend your quantity issued exceed with quantity stock on hand, please see your superior for updating records...&quot;, vbCritical, &quot;Materials & Procurement Management System&quot;
Me.Undo
End If

but my code didn't give me the second msgbox and not do undo my transaction.


could you tell me why this happend?


best regards

Haj1503.
 
You could put the code in the before update event procedure, that way the value wouldn't be saved unless it met your validation criteria and you wouldn't need either the undo or the save docmds.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top