I was under the impression you could write a public function in a MS Access module and then use it in your SQL statements... such as format(expression,"format") which works fine for me.

However I have wrote a function
Code:
Public Function ReturnTotBooked(ByVal lngQuotaID As Long) As Long
When I try to open the following SQL statement as a recordset using ADO:
Code:
SELECT tblQuota.lngSlot,format(MAX(dmyFrom),""hh:nn"") AS [From],
format(MAX(dmyTo),""hh:nn"") AS [To],SUM(intSlots) AS [Total Quota],
ReturnTotBooked([lngQuota]) AS [Total Booked],(SUM(intSlots) - [Total Booked]) AS [Available Slots] 
FROM (tblQuota INNER JOIN tblTimeslots ON tblQuota.lngSlot=tblTimeslots.lngSlot) 
WHERE lngArea=" & Right(lsvAreas.SelectedItem.Key, Len(lsvAreas.SelectedItem.Key) - 1) & _
" AND (dmyDate=DateValue('" & Format(txtDate.Value, "dd/mm/yy") & "')) 
GROUP BY tblQuota.lngSlot
When it is called I get the error function undefined. Does anybody know if there is a reason for this? Is it possible to call VB Functions you write yourself thru SQL?

Thanks for any advice!