0

I am supposed to put a validation to an existing Datawindow field. The requirement is as such. It is character of limit 2 and it is numeric. So whenever the user enters a number it has to be always two character limit or else it should pop a message box. Let say if the user enters number 2 in that field, it should pop up a message saying "You are supposed to enter it as '02' not just 2.

Can somebody help me with this ???

2 Answers2

0

This type of thing is normally handled in the itemchanged event. Since the field is limited to two characters, the entry will have a length of either zero, one, or two.

If it's zero, error.

If it's one, check the entry to see if it's a number (use IsNumber method), if it is display your formatting error, if it's not, error.

If it's two, check the first character (use the Left string method). If that character is not a number (use the IsNumber method), error. If the first character is a number, check that the second character is a number, if it's not, error.

All error conditions should RETURN 1 so that the data value is rejected and the focus does not change.

Make sure you trigger an AcceptText prior to saving the information on the screen.

Matt Balent
  • 2,337
  • 2
  • 20
  • 23
0

Why not just set an edit mask of 00 and it will force it to be that way. No need to display s message.

Roland Smith
  • 957
  • 4
  • 7