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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|