Jump to content
Server Maintenance This Week. ×

Accept Whole Numbers only FM11


mws120

This topic is 5018 days old. Please don't post here. Open a new topic instead.

Recommended Posts

While not being fully aware of the ramifications involved - could one way of dealing with it, be to stuff the fields autoenter option with an updating calc saying:

Round ( Self;0 )

--sd

Link to comment
Share on other sites

Another calculation may be:

Int ( Self )

But with 11, you can trap for the decimal separator, so that nobody can enter that key into the field.

An OnObjectKeystoke trigger that fires a script like this:

If [ Code ( Get ( TriggerKeystroke ) ) = Code ( Left ( 1/2 ; 1 ) ) ]

Show Custom Dialog [ "Only whole number allowed" ]

Exit Script [ Result: 0 ]

End If

Link to comment
Share on other sites

Hi mws120,

I would think that Round() and Int() makes an assumption because it can change the number entered. What are the business rules if someone enters 11.95?

1) Should the number be changed to 12? Use Søren's answer.

2) Should the number be changed to 1195? Use Filter ( Self ; "0123456789" )

3) Should the number be truncated to 11? Use Int(Self).

4) Or should the User be forced to correct it? Use script trigger on keystroke.

On 2, include minus if allowed. Also on the first three auto-enter options, set the auto-enter calculation by unchecking 'do not replace existing value'.

Link to comment
Share on other sites

  • Newbies

Thank you LaRetta

Good thinking "99" re "What are the business rules if someone enters 11.95?"

In this case, I'll be using either option 3 or 4 - but options 1 & 2 may be utilised for other situations as I continue building now that my eyes have been opened a bit more.

Thank you Søren, Danielle and LaRetta

Link to comment
Share on other sites

This topic is 5018 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.