Absence Calendar (1 Viewer)

moodhi

Registered User.
Local time
Today, 07:18
Joined
Oct 19, 2017
Messages
20
OK I have a table to record all employee absence (Events) e.g. Annual Leave, Sickness, Maternity Leave, .... etc. which are in a table with EventID and EventName.

The table which records the above has:
EmployeeNo, EventID, DateStart, DateEnd......etc.

Now I need to produce a daily calendar (for whole year) starting from Current month for each day showing as follows:

Current Month: December 2018
Emp Name 1 2 3 4 5 6 7 8 9 10 11 12 13
Name 01 AL AL
Name 02 Sick Sick
Name 03 AL AL

Current Month: January 2019
Emp Name 1 2 3 4 5 6 7 8 9 10 11 12 13
Name 01 AL ALL
Name 02 AL AL
Name 03 ML ML

Is there a simple Query or a combination of Queries to produce the above?
or if its VBA what is the best approach?
 

Ranman256

Well-known member
Local time
Today, 02:18
Joined
Apr 9, 2015
Messages
4,339
I have a table of every day in the calendar, tCalendar.
make Q1 ,with tCalendar and tAbsence
outer join on date, to show All records in tCalendar, some in tAbsence

then make a crosstab query (use the wizard) using Q1 to show days as columns.
in Q1 make a date field as: yyyymmdd , so the crosstabl will sort them correctly.
 

moodhi

Registered User.
Local time
Today, 07:18
Joined
Oct 19, 2017
Messages
20
Yes but the dates in tAbsence are a range i.e. DateStart to DateEnd. So if the outer join is on DateStart and DateEnd then what about the dates in between?
 

moodhi

Registered User.
Local time
Today, 07:18
Joined
Oct 19, 2017
Messages
20
I think I am stuck because my Absence table is designed as:
EmployeeNo, EventID, DateStart, DateEnd......etc.

Where even though I am looping through all records trying to spread them into basket of daily storage but it is becoming painful to deal with a situation where a date range falls between 2 months e.g. 29 Oct 2018 to 4th Nov 2018.

Would you say that having a table of the above design is wrong?

Is there any way I could tackle the date range above?
 

June7

AWF VIP
Local time
Yesterday, 22:18
Joined
Mar 9, 2014
Messages
5,466
I didn't look at isladogs db but here is another. Absence records use date range, code manipulates this info to generate records in a 'temp' table that is used as the report RecordSource.
 

Attachments

  • GanttChart.mdb
    704 KB · Views: 159
Last edited:

isladogs

MVP / VIP
Local time
Today, 07:18
Joined
Jan 14, 2017
Messages
18,209
Did you look at the example i mentioned? For info, its by oxicottin and not my work.

Here's another by Peter Hibbs with a Gantt chart display that may be very suitable for your needs. Both should at the very least help you deal with your issues

Your table design sounds fine. At least those four fields do.
However it depends what other fields you have as well.

EDIT: Oops - forgot the link to Peter Hibbs example.
Here's two of his apps - both excellent:
https://www.utteraccess.com/forum/index.php?showtopic=2001188&hl=Holiday+planner

https://www.utteraccess.com/forum/index.php?showtopic=1969978&hl=Holiday%20planner&st=0
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:18
Joined
May 21, 2018
Messages
8,525
Yes but the dates in tAbsence are a range i.e. DateStart to DateEnd.
If you want to use a range, relook at Ranman256 suggestion. That will give you a record for each date in the range. You just need a large table of dates to cover all possible days.
 

June7

AWF VIP
Local time
Yesterday, 22:18
Joined
Mar 9, 2014
Messages
5,466
@isladogs, forgot the link to Peter Hibbs

Example in post 6 uses a table with date range fields.
 

moodhi

Registered User.
Local time
Today, 07:18
Joined
Oct 19, 2017
Messages
20
Example (Gantt Chart sample database) in post 6 is exactly what I am after and its how my tables are structured BUT the example does not seem to be working!!! Its not showing all the range in the chart. I am really confused and can't find what can be wrong with the Crosstab query. Any Idea?
 

isladogs

MVP / VIP
Local time
Today, 07:18
Joined
Jan 14, 2017
Messages
18,209
June
Thanks for the prompt. I've added 2 relevant links to post #7 now (both for Peter Hibbs)
 

June7

AWF VIP
Local time
Yesterday, 22:18
Joined
Mar 9, 2014
Messages
5,466
Don't know, it works perfect for me.
 

moodhi

Registered User.
Local time
Today, 07:18
Joined
Oct 19, 2017
Messages
20
Yes, you are right it works perfect in fact really great. I am honestly very grateful and thankful to this great help and the App, it worked absolutely as I needed.

The difference was in the Report Form - the code with hashes around the date did not work for me. I changed them to Format function and it all worked.

You guys are fantastic....
 

Users who are viewing this thread

Top Bottom