Results 1 to 4 of 4
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2003
    Join Date
    Jun 2016
    Posts
    237

    validation rule on a form

    Hi,

    I am having an error in this BeforeUpdate event on a text box on a form.
    Code:
    if me.txtTextBox Is Null OR Not Like "*[!0-9]*" then
    What should I do to allow the user to add a dot (.) also



    The idea is to allow the user to put only digits between 0 - 9 and might have a dot (.) for some fields

    Sincerely yours
    Khalil

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    If IsNull(Me.txtTextBox) or Not IsNumeric(Me.txtTextBox) then

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Dave's code is spot on...but what happens if the user doesn't bother to enter the txtTextBox Control? Your Record will be saved without any Value in it!

    To validate whether a Control is populated or not requires that the code be used in the Form_BeforeUpdate event!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2003
    Join Date
    Jun 2016
    Posts
    237
    Hi,
    Thank you both

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Validation Rule on a form
    By mismag in forum Forms
    Replies: 7
    Last Post: 06-27-2019, 01:34 PM
  2. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  3. Form Validation Rule
    By galkej in forum Forms
    Replies: 4
    Last Post: 07-01-2012, 06:38 PM
  4. Validation Rule in Table vs. Form
    By LanieB in forum Forms
    Replies: 2
    Last Post: 03-12-2012, 03:27 PM
  5. Validation Rule Form AfterUpdate
    By GraemeG in forum Programming
    Replies: 6
    Last Post: 02-09-2011, 10:22 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums