nickgabbard
05-15-2008, 11:57 AM
I have a number field "transfers" in my table, and the values are normally single digits. 99% of the time a double digit value is a user error. Although, 1% of the time it is very possible to have a double digit, even triple digit transfers.
Is there a way to have a box popup if the user enters a double digit value in the input form and say something like "This is an abnormally large value. Are you sure this is correct?"
Any ideas.
georgedwilkinson
05-15-2008, 12:14 PM
Put this code in the After Update event for your control:
Private Sub txtYourControl_AfterUpdate()
If Me.txtYourControl.Value > 9 Then
If MsgBox("Too big, are you sure?", vbYesNo) = vbNo Then
Me.txtYourControl.SetFocus
End If
End If
End Sub
Obviously, it doesn't need to be verbatim...this is just a template for you to use demonstrating the general principle.
There are multiple other approaches you can take. This is the first that came to mind.
Pat Hartman
05-19-2008, 09:41 AM
The code actually needs to go in the control's BeforeUpdate event. That way you can cancel the update.
Private Sub txtYourControl_BeforeUpdate(Cancel as Integer)
If Me.txtYourControl.Value > 9 Then
If MsgBox("Too big, are you sure?", vbYesNo) = vbNo Then
Cancel = True
Exit Sub
End If
End If
End Sub
There is no need to set the focus since the focus has not left the field.