Here is a code example to use in Crystal Reports for displaying missing appointments times in printing a daily schedule where the appointments are coming from a database table, which only has rows for actual appointment times and nothing for the empty appointment times.
After reviewing an example of how to display missing dates, which was posted by James Wiseman on an SAP forum in December 2011, I adapted it to print missing times for a single day's appointment schedule. This involves creating Crystal Reports Custom Functions.
To create Custom Functions in Crystal Reports
Select Reports from Menu
Select Formula WorkShop
Right mouse click on Report Custom Functions
Create New
You will create 3 custom Functions (see attachment for actual code in the Functions )
1) ApptsBeginDay - this will print appointment times from the beginning of the day up to the first actual appointment for the day
2) ApptsBetween - this will print missing appointment times between actual appointments
3) ApptsDaysEnd - this will print missing appointment times after the last actual appointment up to the end of day
To use these Functions you will need to create 4 detail sections (a-d) in your report to reference these Functions
a) Add a Formula to invoke Function ApptsBeginDay - (Code Formula below)
Code: if OnFirstRecord then ApptsBeginDay ({AnAppointmentDateTime}, {?DayStartTime}, 'hh:mm tt', {?ApptLength})
b) The objects to print for an actual appointment
c) Add a Formula to invoke Function ApptsBetween - (Code Formula below)
Code: ApptsBetween ({AnAppointmentDateTime}, next({AppointmentDateTime}), 'hh:mm tt',{?ApptLength})
d) Add a Formula to invoke Function ApptsDaysEnd - (Code Formula below)
Code: if OnLastRecord then ApptsDayEnd ({AnAppointmentDateTime}, {?DayEndTime}, 'hh:mm tt',{?ApptLength})
After placing the Formulas referencing these Functions in their respective detail sections, be sure to format the Formula objects and on
the common tab, check mark 'Can Grow'
The Formulas invoking these Functions each take several arguments which are more clearly identified by reviewing the Functions code
in the attached example.
Please make any modifications you wish to adapt the Functions to your requirements.