Input Masking

LEXCERM

Registered User.
Local time
Tomorrow, 03:46
Joined
Apr 12, 2004
Messages
169
Good morning,

Whenever I set input masks for a currency field, i.e. #####0.00, this allows me to input any figure from 0.00 to 999999.00 which is what I require it to do.

However, if I set the field property to NUMBER and an input mask to ####0, it seems that I have to input proceeding zero's otherwise the field won't accept it, i.e. 00030 instead of just 30.

Is there anyway that I can get a NUMBER field to react in the same way as a CURRENCY field for input masking?

Thanks in advance.

Regards.
 
Technically, I would not consider 00030 a number. Will you be doing any calculations on this information. If not, is there any reason why you couldn't make it a text string? Then your mask should work.
 
Hi Ken and thanks for the swift reply.

Yes, I will be doing calculations on this field. Part of a non-conformance database. I don't want to allow the user to key in a decimal value by mistake. Example: original entry was 10.05, confirmed entry 10 - this would show as a non-conformance because 10 does not equal 10.05.

I have done this without any problem for CURRENCY set fields (####0.00) so if a user keys in £10.505 by mistake it will not accept it (all part of the rounding issues we all know about!)

Regards.
 
Sorry, seems I read the post wrong: You do not want to do leading zero's.

Maybe someone else has an idea on the proper mask...
 
Instead of an input mask I suggest that you test the value keyed using that "fields" BeforeUpdate event. Test if the value keyed is greater than 0 and less than 999999. If the user keyed an invalid entry then you need to cancel the event, reset the field to a Null [or what ever] and make them key a valid number. You should set the field as being required in the table. You can set the format [in the table and in the form!] to display the number of places after the decimal you want displayed but the format in the table for that field must be set to 'single' or 'double'.
Code:
Private Sub TextBox1_BeforeUpdate(Cancel As Integer)
    
    If TextBox1 < 0 Or TextBox1 > 999999 Then
        MsgBox "Invalid number.  Must be between 0 and 999999!", vbCritical
        DoCmd.CancelEvent
        TextBox1.Undo
    End If
    
End Sub
 
Last edited:
Thank you GHudson.

You have solved my problem. Much appreciated.

Regards.
 

Users who are viewing this thread

Back
Top Bottom