Number / list of sessions between 2 dates (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:47
Joined
May 7, 2009
Messages
19,229
you have 2018 year, in your table so I adjust it to date() - 1 year.
the date generated by special_qryDatesFromMsysObjects is from jan-1-2018 up to MAY-18-2045, enough for your all your course scheds.

there is one thing you need to change, the function fncInWeekDay() in Module1.
change:

Weekday(dte)

to:

Weekday(dte, 2)

since your start of the week is Monday (2 vbMonday).

if you have another table for holidays, change the function to accommodate your holiday table:
Code:
Public Function fncInWeekDay(ByVal dte As Date, strWeekDay As String) As Boolean
    Dim intCount As Integer
    fncInWeekDay = (InStr(1, strWeekDay, Weekday(dte, 2) & "") > 0)
    intCount = Nz(DCount("1", "holidayTable", "holidayField=#" & Format(dte, "mm/dd/yyyy") & "#"), 0)
    fncInWeekDay = (fncInWeekday And (intCount = 0))
End Function
happy sunday!
 
Last edited:

Ports

Registered User.
Local time
Today, 14:47
Joined
Jun 30, 2019
Messages
64
Thank you both. You've been most helpful. I'll need to go over the files you've attached. Such a great opportinity to learn new things!
 

Ports

Registered User.
Local time
Today, 14:47
Joined
Jun 30, 2019
Messages
64
you have 2018 year, in your table so I adjust it to date() - 1 year.
the date generated by special_qryDatesFromMsysObjects is from jan-1-2018 up to MAY-18-2045, enough for your all your course scheds.

there is one thing you need to change, the function fncInWeekDay() in Module1.
change:

Weekday(dte)

to:

Weekday(dte, 2)

since your start of the week is Monday (2 vbMonday).

if you have another table for holidays, change the function to accommodate your holiday table:
Code:
Public Function fncInWeekDay(ByVal dte As Date, strWeekDay As String) As Boolean
    Dim intCount As Integer
    fncInWeekDay = (InStr(1, strWeekDay, Weekday(dte, 2) & "") > 0)
    intCount = Nz(DCount("1", "holidayTable", "holidayField=#" & Format(dte, "mm/dd/yyyy") & "#"), 0)
    fncInWeekDay = (fncInWeekday And (intCount = 0))
End Function
happy sunday!


Hi, it's me again. I haven't got to implement the above. First I wanted to replace your magic code wizardy generating the dates for the next 25 years to my Operating Schedule table where the dates span this academic year only (August 2019 - July 2020). The reason I'd like to do it is the fact that apart from standard holidays, it also indicates our custom teaching days off so I'll have to manually update this table every year to mark our custom holidays so I'm happy for now to operate only in this dates span.
Additionally, it seems like Access would freeze for some reason with that long list of dates.


I finally managed to create qrySessionList3 but it complains about data mismatch. Any idea why and which ones are mismatching?


Then I'll try to include the holidays.
 

Attachments

  • Generator - test_v2-arnelgp-mh.zip
    92.6 KB · Views: 141

Ports

Registered User.
Local time
Today, 14:47
Joined
Jun 30, 2019
Messages
64
Hi

I added a Subform to add the various Week Days for the Course.

On the ListSessions Form you just select Course and then View Course

Did not need any Code

View attachment 76213




I've noticed that if a course takes place two days a week, there are 2 rows in qryCourseCodes. Is that necessary?


As you write above, if you select a course and then View course, it displays a report of all the courses, not just the chosen course. Would it be possible to display only the chosen course (listing all the dates for that particular course)?


Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:47
Joined
May 7, 2009
Messages
19,229
there are 3 unfnished records at the bottom of one of the table (the one with general date). there is no date so I just deleted them. now the query is working.
it will be a little slow when loading becoz I added sort order. if you will remove the sorting it will be fast.
I also take your holidaytbl query and use it in the function.
 

Attachments

  • Generator - test_v2-arnelgp-mh.zip
    92.7 KB · Views: 148

Ports

Registered User.
Local time
Today, 14:47
Joined
Jun 30, 2019
Messages
64
Thank you both. Just reporting that I have finished the task taking bits/ideas from your files. Over the last week I have been refining/amending it and populating it with real data.


Thanks again.
 

Users who are viewing this thread

Top Bottom