Sorry I missed this post until now. You may already have fixed it but in case not I've attached a corrected version
Your problem was trying to use Me.txtDateFrom & Me.txtDateTo in the function which creates an error.
Instead of using the table & then running the function, use one of the 2 queries provided as the form record source.
1. frmExampleDCount based on qryExampleDCount - gives result as a text value
2. frmExampleFunction based on qryExampleFunction - result is a number
Personally, I would use the second one