From: James A. Fortune on
On Mar 17, 1:42 pm, "Haggr1 via AccessMonster.com" <u35393(a)uwe> wrote:
> can this be done is the [Table] parameters.  I have multiple forms that use
> this table. Below is a fucntion I use to find records between Thursday and
> Wednesday.
>
> Function LastThurs() As Date
>     'This will find last Thursday's date

Find the date of a particular day that is on or before a given date:

Public Function LEDay(dtX As Date, vbDay As Integer) As Date
LEDay = DateAdd("d", -(7 + WeekDay(dtX) - vbDay) Mod 7, dtX)
End Function

Example (Note: vbThursday = 5):

LEDay(#3/17/10#, 5) => 3/11/10
LEDay(#3/18/10#, 5) => 3/18/10
LEDay(#3/19/10#, 5) => 3/18/10

Perhaps loop through some dates using the DateAdd() function to see if
the function gives the same results as yours, then see if it works for
any weekday selected.

James A. Fortune
MPAPoster(a)FortuneJames.com

My parents were factory workers who never went to college.
From: John W. Vinson on
On Thu, 18 Mar 2010 20:39:07 GMT, "Haggr1 via AccessMonster.com" <u35393(a)uwe>
wrote:

>Can this code be added to the Table somehow.

Not to the Table, no. Tables have no usable events and table validation rules
cannot call user functions.

You will need to enforce that data is added and edited only through Forms, and
use this code in the appropriate Form event.
--

John W. Vinson [MVP]
From: Haggr1 via AccessMonster.com on
All of my queries that I use to find records opens with a "datasheet". How
might I protect the records that are "older" than the preceeding "Thursday"
from being edited? Thanks

John W. Vinson wrote:
>>Can this code be added to the Table somehow.
>
>Not to the Table, no. Tables have no usable events and table validation rules
>cannot call user functions.
>
>You will need to enforce that data is added and edited only through Forms, and
>use this code in the appropriate Form event.

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

From: John W. Vinson on
On Fri, 19 Mar 2010 19:04:27 GMT, "Haggr1 via AccessMonster.com" <u35393(a)uwe>
wrote:

>All of my queries that I use to find records opens with a "datasheet". How
>might I protect the records that are "older" than the preceeding "Thursday"
>from being edited? Thanks

You can't, in a query datasheet. That's one of many reasons to NOT use query
datasheets for user interaction; if the user can open a table or an editable
query, then they have no barriers to doing anything.
--

John W. Vinson [MVP]