 | Member with 56 posts. | | Join Date: Jan 2009 Location: Ottawa, Canada Experience: Intermediate | | Solved: Access 2007: Validation Rule for Time Hiya!
This is probably super easy, I just can't seem to figure out how to do it.
I have a Date/Time field in a table, which is in "Short Time" format. I want people to only be able to enter times in increments of 30 minutes.
Is there some way to put in a validation rule to "only allow times that have a 'minutes' value of '00' or '30'"?
Many thanks! | | Distinguished Member with 9,329 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | This can be doen using VBA in the Field's After Update Event Procedure.
This works for a Filed called "Hours"
Dim min As String
minutes = Right((Format(Me.Hours, "hh:mm")), 2)
If minutes <> "30" And minutes <> "00" Then
MsgBox "minutes must be either 30 or 00"
Me.Hours = ""
End If
__________________ OBP
I do not give up easily | | Member with 56 posts. | | Join Date: Jan 2009 Location: Ottawa, Canada Experience: Intermediate | | Thanks for the quick reply! I forgot to mention, I need it without using VBA. And please don't ask why haha, I'm tired of explaining why I can't use VBA.  thanks! | | Distinguished Member with 9,329 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | The time/date is stored as a number, it is only the format that makes it 00 or 30 so put this in the Validation Rule
Right((Format([Hours],"hh:mm")),2)="00" Or Right((Format([Hours],"hh:mm")),2)="30" | | Member with 56 posts. | | Join Date: Jan 2009 Location: Ottawa, Canada Experience: Intermediate | | Except that it needs to be in Time/Date format.
Okay I guess I need to be more clear.... haha sorry.
These are musts:
-the field is in Time/Date format
-users can only enter times in increments of 30 minutes
-not a drop-down list - users need to be able to enter the time by typing it into the table directly
- No VBA/SQL: needs to be set up right in the table design window
Many thanks! | | Distinguished Member with 9,329 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | The answer I provided does what you want, I have tested it. | | Member with 31 posts. | | Join Date: May 2009 Location: Ottawa, Canada Experience: Intermediate | | I think this will do exactly what you need:
Minute([NameOfYourField])=0 Or Minute([NameOfYourField])=30 | | Member with 56 posts. | | Join Date: Jan 2009 Location: Ottawa, Canada Experience: Intermediate | | | |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 04:00 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|