Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2010

    Unanswered: Access prompts user to change data type from number to text

    I have a number field that has a validation rule of ">=0" to ensure a positive number from the user, however, if the user types in text, then Access asks them if they would like to convert the entire field to a text data type. I need this field to be a number (hence I defined it that way), how do I prevent access from asking my many users if they want to convert this field to a text field?

  2. #2
    Join Date
    May 2010
    Try using the On KeyPress event to filter to only numeric input:

    Private Sub txtNumericOnly_Keypress(ByVal KeyAscii As MSForms.ReturnInteger)
        Select Case KeyAscii
        Case 8 ' backspace/delete
            ' always allow this key
        Case 48 to 57 ' Asc("0") to Asc("9")
            ' allow these characters
        Case Else
            ' reject these characters
            KeyAscii = 0
        End Select
    End Sub
    Boyd Trimmell aka HiTechCoach (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts