Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calender with Selection for Non Work Days

Status
Not open for further replies.

rwn

Technical User
Dec 14, 2002
420
0
0
US
Is there a way to have a Calender in Access, that a user can hilight (for example Saturdays & Sunday) as a NON Work day(s). The objective is to control if a Job is calculated to start ON a NON Work day, it is then automatically moved to back to the closest work day on the calender to start ON.
 
faq222-5185
This may be helpful to check for a holiday. Checking for a weekend is simple just use the "weekday" function and check for a 7 or 1.
 
How are ya rwn . . .

To check for weekends only:
Code:
[blue]Public Function adjWorkDate(ByVal usrDate As Date) As Date
   
   [green]'Adjust for weekend.[/green]
   If Weekday(usrDate) = 1 Then [green]'Sunday[/green]
      usrDate = usrDate - 2
   ElseIf Weekday(usrDate) = 7 Then [green]'Saturday[/green]
      usrDate = usrDate - 1 
   End If
   
   adjWorkDate = usrDate
   
End Function[/blue]
To check for weekends & holidays (table of holiday dates required):
Code:
[blue]Public Function adjWorkDate(ByVal usrDate As Date) As Date
   Dim Cri As String
   
   Cri = "[holDate] = #" & Format(usrDate, "yyyy/mm/dd") & "#"
   
   [green]'Adjust for holiday.[/green]
   If Not IsNull(DLookup("[holDate]", "tblHolidays", Cri)) Then
      usrDate = usrDate - 1
   End If
   
   [green]'Adjust for weekend.[/green]
   If Weekday(usrDate) = 1 Then [green]'Sunday[/green]
      usrDate = usrDate - 2 
   ElseIf Weekday(usrDate) = 7 Then [green]'Saturday[/green]
      usrDate = usrDate - 1
   End If
   
   adjWorkDate = usrDate
   
End Function[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I most likely didn't make my request clear enough. It isn't that I want to auto make Sat & Sun NON Work days. I need to be able to select any day on a calender and make them a non work day. So any day can be a non-work day, and maybe it sets up a Boolean as a NO when selected and a YES if not selected.
 
Where do you want to store the non-work days? You should have a table to store these dates possibly with their name. Then you create a form that allows you to enter/edit the dates. You can use a calendar from my link above to make entering dates easier.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top