santastefano
Programmer
I have a routine that creates a timetable based on user input of the first date - it just adds 7 days.
As an enhancement I wanted to make it check for holidays when the business would be closed. I thought a good method would be a table of holiday dates and use DLokkup but I keep getting the "You cancelled the previous event" error message at the DLookup line.
I am using:
I have tried commenting out the CancelEvent in the time check
All references to dates and times are actual dates and times.
Any suggestions enthusiastically received.
Best regards
George
As an enhancement I wanted to make it check for holidays when the business would be closed. I thought a good method would be a table of holiday dates and use DLokkup but I keep getting the "You cancelled the previous event" error message at the DLookup line.
I am using:
Code:
Dim DB As DAO.Database
Dim rsTimeTable As DAO.Recordset
Set DB = CurrentDb
Set rsTimeTable = DB.OpenRecordset("tblTimetable", dbopendynaset)
Dim varSessionsTotal As Integer
Dim varSessionsPerWeek As Integer
Dim varStartDate As Date
Dim varCode As String
Dim varTime1, varTime2 As Date
varSessionsPerWeek = Forms!frmCourseStart!SessionsWeek
varTime1 = Me.Time1
varTime2 = Me.Time2
If varTime1 > varTime2 Then
DoCmd.CancelEvent
Reply = MsgBox("The finish time you entered for this session is earlier than the start time", 16, "School Run")
DoCmd.GoToControl "Time1"
ElseIf varSessionsPerWeek = 1 Then
varSessionsTotal = Forms!frmCourseStart!TotalSessions
varCode = Forms!frmCourseStart!Code
varStartDate = Me.Date1
If varStartDate = DLookup("[Booking]", "tblHolidays", "[Booking] = varStartDate") Then
varStartDate = Me.Date1 + 7
Else
End If
All references to dates and times are actual dates and times.
Any suggestions enthusiastically received.
Best regards
George