VBA If statement error

Leopard011

New member
Local time
Yesterday, 20:40
Joined
Jan 14, 2012
Messages
9
Dear All,

I have a simple equation to check if the materials in warehouse are sufficient for use as required or not

I wrote a label to alert the user if there is no sufficient amount for use

So, if the required material has sufficient amount , I need the alert to be invisible

The problem is, when I enter quantity more than available in warehouse, the label is shown as required.

After I modify the amount and decrease it, the label is not going to be hidden

My code is as follows:

Private Sub M_Q_AfterUpdate()
x = Me.M_Quantity.Value
y = Me.M_Available.Value
If y < x Then
Me.Label29.Visible = True
Else
Me.Label29.Visible = False
End If
End Sub

I don't know where is the error although its very simple if statement :mad:
 
L,

Why are you checking --> ".M_Quantity.Value" in the "M_Q_AfterUpdate" event?

Did you change the variable name?

Otherwise, things look OK.

Wayne
 
Dear Wayne;

I've put the code in after update event because it's the field where I write the required material amount and before i go to the record button which trigger the save event

to be like this:

1- the required materials in >> M_Q
2- the available materials in >> M_Available
3- Button to run append query for the amount required

So, first check the amount between no1 and no2
then display warning or not (label29) before I go to no3

any alternatives for the afterupdate event?
 

Users who are viewing this thread

Back
Top Bottom