input mask

  • Thread starter Thread starter JohnLute
  • Start date Start date
J

JohnLute

I have a field formatted to FIXED with 2 decimals. It should never contain a
number greater than "1".

Can I mask this to assure it contains values that are "1" or less?

Thanks for your help!
 
An Input Mask will not do this for you. You can either put a validation rule
on the table field to contrain it to be <= 1 Or you can check it in the
Before Update event of your form:

If Me.MyControl > 1 Then
MsgBox "Cannot be More Than 1"
Cancel = True
Me.MyControl.SetFocus
End If

That will cancel the update and return you to the control. MyControl should
be changed to the actual name of the control on your form that is bound to
the field.
 
Thanks, Klatuu!

I like the BeforeUpdate approach better. It helps a user understand the
error more clearly. The validation rule returns a funky looking message that
I think users will find annoying.

The downside is that within a query or the actual table a "bad" value can be
entered. I guess you can't have your cake and eat it, too.
 
In Jet, I never use field validation because of the funky messsage. As to
the query, that is a design issue. Just as an idea, you could consider
creating a select query with the same filtering as your action query that
might update the field. And add a criteria of > 1 to the field. You could
then use it to see if there were any invalid values that might get into the
table.
 
Great tip! Thanks, Dave!
--
www.Marzetti.com


Klatuu said:
In Jet, I never use field validation because of the funky messsage. As to
the query, that is a design issue. Just as an idea, you could consider
creating a select query with the same filtering as your action query that
might update the field. And add a criteria of > 1 to the field. You could
then use it to see if there were any invalid values that might get into the
table.
 
Back
Top