Hi Again -
I decided to try a Sunday morning challenge to try to help you more. If the SessionStart and SessionEnd dates fall within a single month, then you can use a query--no VBA code required. For this example, I named the table "tblTrainingSessions". The fields are named "SessionStart" and "SessionEnd", respectively, and are both Date/Time data type formatted as you indicated (dd/mm/yyyy). Here is some sample data that I entered into the table. TrainingID is simply an Autonumber primary key:
Data.gif
The test data includes your original dates, a set of dates that spans two months, your original dates entered backwards, and two records with nulls.
Query1 SQL Statement
SELECT SessionStart, SessionEnd, Day([SessionStart]) & "-" & Day([SessionEnd]) & " " & Format([SessionStart],"mmmm yyyy") AS TrainingSession
FROM tblTrainingSessions;
Query1 Result with above test data:
Q1.gif
As you can see, the last four results have an error. You can eliminate results # 4 and 5 by adding the appropriate criteria to the query, but that still leaves the 2nd and 3rd results:
SELECT SessionStart, SessionEnd, Day([SessionStart]) & "-" & Day([SessionEnd]) & " " & Format([SessionStart],"mmmm yyyy") AS TrainingSession
FROM tblTrainingSessions
WHERE SessionStart Is Not Null AND SessionEnd Is Not Null;
Query that calls VBA procedure
Create a new module and paste the following code into this module. Make sure that your new module has "Option Explicit" as the second line:
SQL Statement for Query that calls VBA procedure:
SELECT SessionStart, SessionEnd, DetermineRange([SessionStart],[SessionEnd]) AS TrainingSession
FROM tblTrainingSessions;
Here is the result of this query:
Q2.gif