Problem with Dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top