User Input Validation

  • Follow


I have  a form that allows editing, single form view.

I want to validate each field for valid entries:
     Using IsNumeric etc.
     Is within a certain range.

When I perform this validation using Before_Update, I am receiving the 
following error..."You must save the field before you execute the GoToControl 
action, the GoToControl method, or the SetFocus method."

Here is my code:
Private Sub datReminderInterval_BeforeUpdate(Cancel As Integer)
    If Me.datReminderInterval.Value < 1 Or _
            Me.datReminderInterval.Value > 60 Or _
            IsNull(Me.datReminderInterval) Or _
            Not IsNumeric(Me.datReminderInterval) Then
        DoCmd.SetWarnings False
        MsgBox "Value must be 1 - 60", vbCritical + vbApplicationModal + 
vbOKOnly, "Invalid data entry"
        Cancel = True
        Me.datReminderInterval.SetFocus
        DoCmd.SetWarnings True
        Exit Sub
    End If
End Sub


Hellllllllp.....Thank you.
0
Reply Utf 1/13/2010 11:46:01 PM

DISREGARD...I figured it out that I didn't need the setfocus statement since 
I was cancelling the event.

Thank you though.

"PosseJohn" wrote:

> I have  a form that allows editing, single form view.
> 
> I want to validate each field for valid entries:
>      Using IsNumeric etc.
>      Is within a certain range.
> 
> When I perform this validation using Before_Update, I am receiving the 
> following error..."You must save the field before you execute the GoToControl 
> action, the GoToControl method, or the SetFocus method."
> 
> Here is my code:
> Private Sub datReminderInterval_BeforeUpdate(Cancel As Integer)
>     If Me.datReminderInterval.Value < 1 Or _
>             Me.datReminderInterval.Value > 60 Or _
>             IsNull(Me.datReminderInterval) Or _
>             Not IsNumeric(Me.datReminderInterval) Then
>         DoCmd.SetWarnings False
>         MsgBox "Value must be 1 - 60", vbCritical + vbApplicationModal + 
> vbOKOnly, "Invalid data entry"
>         Cancel = True
>         Me.datReminderInterval.SetFocus
>         DoCmd.SetWarnings True
>         Exit Sub
>     End If
> End Sub
> 
> 
> Hellllllllp.....Thank you.
0
Reply Utf 1/14/2010 12:24:01 AM


1 Replies
215 Views

(page loaded in 0.06 seconds)

Similiar Articles:
















7/22/2012 7:55:14 PM


Reply: