reference a function Please help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

my function looks is as follows... How do I use that funtion in a query?

Public Function Holidays(BeginDate As Date, EndDate As Date) As Integer
Holidays = DCount("*", "Holiday", "HdyDate Between " & _
Format$(BeginDate, "\#mm\/dd\/yyyy\#") & _
" And " & Format$(EndDate, "\#mm\/dd\/yyyy\#") & _
" And Weekday(HdyDate, 1) <> 1 " & " And Weekday(HdyDate, 1) <> 7 ")

End Function
 
Open a query in design mode.

Enter the following in one of the empty field "cells"
=Holidays([YourBeginDateFieldName], [YourEndDateFieldName])
and <tab> out of the cell.

Access will add "Expr1:" in front of your expression -- feel free to change
this descriptive title of the field.

Regards

Jeff Boyce
<Office/Access MVP>
 
Thanks alot, that worked perfect

Jeff Boyce said:
Open a query in design mode.

Enter the following in one of the empty field "cells"
=Holidays([YourBeginDateFieldName], [YourEndDateFieldName])
and <tab> out of the cell.

Access will add "Expr1:" in front of your expression -- feel free to change
this descriptive title of the field.

Regards

Jeff Boyce
<Office/Access MVP>

JOM said:
my function looks is as follows... How do I use that funtion in a query?

Public Function Holidays(BeginDate As Date, EndDate As Date) As Integer
Holidays = DCount("*", "Holiday", "HdyDate Between " & _
Format$(BeginDate, "\#mm\/dd\/yyyy\#") & _
" And " & Format$(EndDate, "\#mm\/dd\/yyyy\#") & _
" And Weekday(HdyDate, 1) <> 1 " & " And Weekday(HdyDate, 1) <> 7 ")

End Function
 
Back
Top