A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I setup a date field property that allows only Saturdays?



 
 
Thread Tools Display Modes
  #1  
Old March 12th, 2010, 03:44 AM posted to microsoft.public.access.tablesdbdesign
jaymalea
external usenet poster
 
Posts: 1
Default How do I setup a date field property that allows only Saturdays?

For example:

03/13/2010 would be fine, as that is a Saturday. 03/12/2010 would return an
error message as it is a Friday.

How would I create a field property for this, or would I use a different
aspect of Access creation?
  #2  
Old March 12th, 2010, 04:17 AM posted to microsoft.public.access.tablesdbdesign
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default How do I setup a date field property that allows only Saturdays?

jaymalea wrote:
For example:

03/13/2010 would be fine, as that is a Saturday. 03/12/2010 would return an
error message as it is a Friday.

How would I create a field property for this, or would I use a different
aspect of Access creation?


Private Sub txtSaturday_BeforeUpdate(Cancel As Integer)
If Not Weekday(Me.txtSaturday) = vbSaturday Then
MsgBox "Not a Saturday!"
Cancel = True
End If
End Sub

--
Message posted via http://www.accessmonster.com

  #3  
Old March 12th, 2010, 06:52 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default How do I setup a date field property that allows only Saturdays?

Open the table in design view, select the Date/Time field, and set these
properties:
- Validation Rule: ([SatOnly] Mod 7)=0
- Validation Text: Must be a Saturday

Replace the SatOnly with the name of your field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"jaymalea" wrote in message
...
For example:

03/13/2010 would be fine, as that is a Saturday. 03/12/2010 would return
an
error message as it is a Friday.

How would I create a field property for this, or would I use a different
aspect of Access creation?


  #4  
Old March 12th, 2010, 07:24 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default How do I setup a date field property that allows only Saturdays?

On Thu, 11 Mar 2010 18:44:01 -0800, jaymalea
wrote:

For example:

03/13/2010 would be fine, as that is a Saturday. 03/12/2010 would return an
error message as it is a Friday.

How would I create a field property for this, or would I use a different
aspect of Access creation?


Might it not be better to have the textbox just adjust itself to the next (or
previous) Saturday instead? You can use DateAdd() in the textbox's afterupdate
event to reset the date:

Private Sub txtSaturday_AfterUpdate()
If Weekday(Me!txtSaturday) vbSaturday Then
Me!txtSaturday = DateAdd("d", 7 - Weekday(Me!txtSaturday))
MsgBox "Adjusted date to Saturday, " & format(Me!txtSaturday, "dd-mmm-yyyy")
End If
End Sub
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.