Results 1 to 5 of 5

Thread: validation

  1. #1
    Join Date
    Feb 2006
    Posts
    2

    Question Unanswered: validation

    how can i validate a field so that its maximum number of characters is X amount and a message box appears saying whats wrong?
    Any help greatly appreciated

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    here's one way:

    use a surrogate unbound field
    if len(boxSurro) > 99 then
    msgbox "boo"
    else
    boxRealButNotVisible = boxSurro
    endif

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Feb 2006
    Posts
    2
    how can i do that with a normal field??

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    weeeeell, i'm not the person to talk to about bound forms 'cos i didn't use them for 9 years.

    since nobody else answered yet, my guess would be to look at the _BeforeUpdate() event for your box and see if you can get a result from len(myBox), and maybe try a Cancel = True or something like it if > 99

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    The above suggestions require you to have some knowledge of events and VBA. This is useful particularly with complex validations. However, you can do what you want using the validation rule attribute

    You can put len([boxSurro])<=99 in the validation rule for the boxSurro control (on your form). Then put some appropriate text in the validation text attribute.

    hth
    Chris

Posting Permissions

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