Problem with Dates

D

Don

I have a date control on my form. When the form is opened, I want this
control to display the next scheduled workday. I tried (control) = Date +1,
but could not get this to work. Can someone point out what I'm doing wrong?
Thanks...
 
A

Al Campagna

Don,
I'm assuming you mean that when you open a new record, that date field should always
display tomorrow's date.
Set the field's DefaultValue to
= Date() +1
If that's not what you need, please provide more info...
 
K

Klatuu

Here are a pair of functions that will provide the information you want. It
includes a Holiday table that has a record for each company holiday. It does
not inlcue week end dates, only week day dates that are not working days.

You can use the Default Value property of your date control to populate the
date:

=NextWorDay(Date())

Be sure to use the parentheses with the date.


Public Function NextWorkDay(dtmSomeDay As Date)

dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Do Until IsWorkDay(dtmSomeDay)
dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Loop
NextWorkDay = dtmSomeDay
End Function
******************************************
Public Function IsWorkDay(dtmSomeDay As Date) As Boolean
Dim blnWorkingDay
blnWorkingDay = Weekday(dtmSomeDay, vbMonday) < 6
If blnWorkingDay Then
blnWorkingDay = IsNull(DLookup("[Holdate]", "Holidays", _
"[Holdate] = #" & dtmSomeDay & "#"))
End If
IsWorkDay = blnWorkingDay
End Function
 
Top