Hi,
I have this field 'Amount' on a subform 'sfrmOrders'. Every time a product is choosen (from a listbox on the main form) it is inserted in the subform and the 'Amount' is set to 1.
Now, whenever the 'Amount' of a certain product is changed on the subform, the total cost of the order (Sum(amount*price)) is changed as well immediately (as I requery whenever an amount is changed).
Private Sub Amount_Change()
Me.Requery
End Sub
Now, I would like to have a validation on the field were the amount has to be filled in. It should be > 0 and it should also be a number.
I tried to put the validation on the field 'Amount' in the table, but then I get an error on the Requery event.
Then I tried this:
Private Sub Amount_Change()
If (Me!Amount < 1) Then
MsgBox "The amount has to be more than 0!"
Me.Undo
Me!Amount = 1
Me.Requery
Else
Me.Requery
End If
End Sub
This works, but somehow it only works for the first line on the subform?
Could someone please give me some advice?
Thanks in advance,
dj.
I have this field 'Amount' on a subform 'sfrmOrders'. Every time a product is choosen (from a listbox on the main form) it is inserted in the subform and the 'Amount' is set to 1.
Now, whenever the 'Amount' of a certain product is changed on the subform, the total cost of the order (Sum(amount*price)) is changed as well immediately (as I requery whenever an amount is changed).
Private Sub Amount_Change()
Me.Requery
End Sub
Now, I would like to have a validation on the field were the amount has to be filled in. It should be > 0 and it should also be a number.
I tried to put the validation on the field 'Amount' in the table, but then I get an error on the Requery event.
Then I tried this:
Private Sub Amount_Change()
If (Me!Amount < 1) Then
MsgBox "The amount has to be more than 0!"
Me.Undo
Me!Amount = 1
Me.Requery
Else
Me.Requery
End If
End Sub
This works, but somehow it only works for the first line on the subform?
Could someone please give me some advice?
Thanks in advance,
dj.