Gasman
Enthusiastic Amateur
- Local time
- Today, 13:57
- Joined
- Sep 21, 2011
- Messages
- 14,465
Hi all,
How does one handle form validation and a new record?
I have the following code for validation on a form.
As you can see I am trying to handle a new record and validate if not a new record, (commented out for now) however I still need to validate if it is new record?
So how does one handle this situation?
At present as soon as I add the new record, I get the error messages below. Ok'ing through them eventually allows me to enter data, but I do not want to see them when adding a new record unless I have missed a control, but this is happening before I have the chance to enter any data.?
TIA
How does one handle form validation and a new record?
I have the following code for validation on a form.
As you can see I am trying to handle a new record and validate if not a new record, (commented out for now) however I still need to validate if it is new record?
So how does one handle this situation?
At present as soon as I add the new record, I get the error messages below. Ok'ing through them eventually allows me to enter data, but I do not want to see them when adding a new record unless I have missed a control, but this is happening before I have the chance to enter any data.?
TIA
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error Resume Next
'If Not Me.NewRecord Then
If IsNull(Me.cboFeeTypeID) Then
Cancel = True
'Me.Undo
Me.Dirty = False
MsgBox "Fee Type is mandatory"
End If
If Nz(Me.FeeAmount, 0) = 0 Then
Cancel = True
'Me.Undo
Me.Dirty = False
MsgBox "Fee amount must be > £0"
End If
'End If
End Sub