Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: MS Access Validation Rule - Time

    Hello all, I'm new here, but this looks like a good community to join discussing database issues.

    Anyhow, here it goes, I am curious if there is anyone who would be willing to help me with a validation rule or something that ties in with an input mask I have.

    I am making a database for music CDs and I have a time setup like:


    ... for the minutes and seconds the song track runs for.

    Now what I am trying to figure out is a way to make a rule to stop me or anyone from going past 59 seconds, like a song cannot be:


    ... it would be:


    So if anyone has any ideas or experience with this sort of thing, please let me know, thanks for taking the time to read this! =)

  2. #2
    Join Date
    Sep 2003
    Caldes de Malavella, Spain
    Hello nucleartiger, and welcome to the community!!

    You won't be able to do this with an input mask - it just doesn't have the verification facilities that you need. A mask like 00:00 would force the user to enter four digits, but then it doesn't check the seconds for being>59 because that's not the job of an input mask. So, what you need to do is to verify the data after it has been entered. On the form, you would use the text box's AfterUpdate event. Because the input mask will be forcing the entry of four digits, we know that the rightmost two digits represent the seconds. You can write code for the AfterUpdate event that will:

    1. Strip out the right-most two digits
    2. Check to see if they are >59
    3. Generate an error for the user if so.

    Alternatively, if somebody enters 65 seconds, your code could add one to the minutes figure and 5 to the seconds figure.

    Hope that this has given you something to think about!!
    Andy Briggs
    Elmhurst Solutions Limited
    Database Development and Consultancy

  3. #3
    Join Date
    Mar 2004

    Thumbs up

    Thanks for your help, I really appreciate the reply.

Posting Permissions

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