I have created the tables and module following the instructions on microsoft's page.
http://support.microsoft.com/kb/210064/en-us
The Module is:
Function OfficeClosed(TheDate) As Integer
OfficeClosed = False
TheDate = Format(TheDate, "dd/mm/yyyy")
' Test for Saturday or Sunday.
If WeekDay(TheDate) = 1 Or WeekDay(TheDate) = 7 Then
OfficeClosed = True
' Test for Holiday.
ElseIf Not IsNull(DLookup("HoliDate", "Holidays", "[HoliDate]=#" _
& TheDate & "#")) Then
OfficeClosed = True
End If
End Function
I tested it in the immediate window in VB and it works ok.
-----------------------
Now..... for usage on my form:
I have an OrderDate field that inputs today's date automatically as the default value. I used =Date()
Then I have an InvoiceDate field that needs to add 2 days to the OrderDate but also avoid Saturday, Sunday and Holidays listed on the Holidays table.
______________________
The function listed on MS is ........
DueDate=OrderDate+30
Do While OfficeClosed(DueDate)
DueDate=DateDue+1
Loop
Where do I put that on my form? Within the field properties on invoice date and where - an event, the control source, the default? Do I replace the word duedate with something else or leave as is?
I'm confused as to where to put it. I've tried numerous ways to do this and am stumped as it is new to me to work with the module.
Thanks.
http://support.microsoft.com/kb/210064/en-us
The Module is:
Function OfficeClosed(TheDate) As Integer
OfficeClosed = False
TheDate = Format(TheDate, "dd/mm/yyyy")
' Test for Saturday or Sunday.
If WeekDay(TheDate) = 1 Or WeekDay(TheDate) = 7 Then
OfficeClosed = True
' Test for Holiday.
ElseIf Not IsNull(DLookup("HoliDate", "Holidays", "[HoliDate]=#" _
& TheDate & "#")) Then
OfficeClosed = True
End If
End Function
I tested it in the immediate window in VB and it works ok.
-----------------------
Now..... for usage on my form:
I have an OrderDate field that inputs today's date automatically as the default value. I used =Date()
Then I have an InvoiceDate field that needs to add 2 days to the OrderDate but also avoid Saturday, Sunday and Holidays listed on the Holidays table.
______________________
The function listed on MS is ........
DueDate=OrderDate+30
Do While OfficeClosed(DueDate)
DueDate=DateDue+1
Loop
Where do I put that on my form? Within the field properties on invoice date and where - an event, the control source, the default? Do I replace the word duedate with something else or leave as is?
I'm confused as to where to put it. I've tried numerous ways to do this and am stumped as it is new to me to work with the module.
Thanks.