It would be useful if you would post the code snippet in The thread as many of us use mobile phones which are not able to run MS Access.
If (IsNull(Me.AMOUNTs) Or (Me.AMOUNTs = 0)) Then
If MsgBox("Did you miss AMOUNT?", vbDefaultButton1 + vbYesNo + vbQuestion) = vbYes Then
Me.AMOUNTs.SetFocus
Cancel = True
End If
End If
Use the following code in the forms BeForeUpDate event:
Code:If (IsNull(Me.AMOUNTs) Or (Me.AMOUNTs = 0)) Then If MsgBox("Did you miss AMOUNT?", vbDefaultButton1 + vbYesNo + vbQuestion) = vbYes Then Me.AMOUNTs.SetFocus Cancel = True End If End If
I don't think that it will work on an existing record if user deletes the amount. Best to test for Null as well as 0, just in case.The field is currency. By default it shows Rs. 0.00. If someone crosses over without entering, how do I check? Will -> If (Me.AMOUNTs = Rs. 0.00) work?
I don't think that it will work on an existing record if user deletes the amount. Best to test for Null as well as 0, just in case.
The field is currency. By default it shows Rs. 0.00. If someone crosses over without entering, how do I check? Will -> If (Me.AMOUNTs = Rs. 0.00) work?
I am attaching the changes. But it is not working properly.I don't think that it will work on an existing record if user deletes the amount. Best to test for Null as well as 0, just in case.
I suspect that it "is not working properly" because you have not put the code in the FORMs BeforeUpdate event as I suggested in my earlier post.
Try the attached db:
It does work in the controls Before Update event but you need to remove the "setfocus" line as that is not needed and will throw an error. I think you had the code in the controls AfterUpdate event.Yes it works in the forms' Before Update event. Why is it not possible in the AMOUNTs Before Update event?
So why not use the FORMs Before Update event. I am not at a computer today but will look at your db tomorrow.I put it in the Before Update of the control , but it is not working.
First of all, please accept my sincere apologies for not replying sooner as I had promised.I put it in the Before Update of the control , but it is not working.
Private Sub AMOUNTs_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.AMOUNTs) Or (Me.AMOUNTs = 0)) Then
If MsgBox("Did you miss AMOUNT?", vbDefaultButton1 + vbYesNo + vbQuestion) = vbYes Then
Cancel = True
Me.Undo
End If
End If
End Sub
Placing it in the Control's BeforeUpdate event is useless!Why is it not possible in the AMOUNTs Before Update event?
I agree entirely with you missingling, which is why I advised the use of the form's BeforeUpdate event in post #5 and #8Placing it in the Control's BeforeUpdate event is useless!
All the user has to do, in order to make your validation useless...is to simply not enter the Amounts Control! If the Control is never entered...none of its events are executed!
Validation for determining if a Control is populated simply has to be in the Form_BeforeUpdate event...as does validation involving two or more Controls...such as ControlB must be greater than ControlA, etc.
Validation used in a Control's BeforeUpdate is used to ensure that data that has actually been entered meets a requirement...such as 'greater than current date,' or 'must include at least one Alpha character,' etc.
Linq ;0)>
How would the code be in the BeforeUpdate event of the control?Placing it in the Control's BeforeUpdate event is useless!
All the user has to do, in order to make your validation useless...is to simply not enter the Amounts Control! If the Control is never entered...none of its events are executed!
Validation for determining if a Control is populated simply has to be in the Form_BeforeUpdate event...as does validation involving two or more Controls...such as ControlB must be greater than ControlA, etc.
Validation used in a Control's BeforeUpdate is used to ensure that data that has actually been entered meets a requirement...such as 'greater than current date,' or 'must include at least one Alpha character,' etc.
Linq ;0)>
I agree entirely with you missingling, which is why I advised the use of the form's BeforeUpdate event in post #5 and #8