There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash drive driver drivers error ethernet excel freeze games gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram random registry router slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Access 2007: Validation Rule for Time

Reply  
Thread Tools
look_b4u_leap's Avatar
Computer Specs
Member with 58 posts.
 
Join Date: Jan 2009
Location: Ottawa, Canada
Experience: Intermediate
10-Aug-2009, 09:04 PM #1
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!
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
11-Aug-2009, 08:55 AM #2
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
look_b4u_leap's Avatar
Computer Specs
Member with 58 posts.
 
Join Date: Jan 2009
Location: Ottawa, Canada
Experience: Intermediate
11-Aug-2009, 08:59 AM #3
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!
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
11-Aug-2009, 09:36 AM #4
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"
look_b4u_leap's Avatar
Computer Specs
Member with 58 posts.
 
Join Date: Jan 2009
Location: Ottawa, Canada
Experience: Intermediate
11-Aug-2009, 03:16 PM #5
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!
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
11-Aug-2009, 03:42 PM #6
The answer I provided does what you want, I have tested it.
Stacers's Avatar
Member with 53 posts.
 
Join Date: May 2009
Location: Toronto, Canada
Experience: Intermediate
11-Aug-2009, 03:42 PM #7
I think this will do exactly what you need:

Minute([NameOfYourField])=0 Or Minute([NameOfYourField])=30
look_b4u_leap's Avatar
Computer Specs
Member with 58 posts.
 
Join Date: Jan 2009
Location: Ottawa, Canada
Experience: Intermediate
11-Aug-2009, 03:46 PM #8
Many thanks!
Reply

Tags
access, validation rule

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:31 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.