Been using Access for a while now but never had Modules explained to me. Now I'm trying to use them and just getting thougroughly confused. I have searched this forum for solutions but it hasn't helped (so far)...I think I'm over complicating things
Basically I have a module ('borrowed' from this forum)
Function SLADays(FromDt As Date, ToDt As Date) As Integer
' counts the number of business days between two dates (holidays are pulled from tblHolidays).
Dim CheckDate As Date
SLADays = 0
CheckDate = FromDt
Do Until CheckDate > ToDt
If WeekDay(CheckDate) <> 1 And WeekDay(CheckDate) <> 7 And _
IsNull(DLookup("Date", "tblHoliday", "[Date]=#" & CheckDate & "#")) Then
SLADays = SLADays + 1
CheckDate = CheckDate + 1
SLADays = IIf(SLADays > 0, SLADays - 1, SLADays)
Me.Result = SLADays
I want to use this in various forms (and possibly later to amend tables)
Firstly I'm looking to get this to work from a button click and just display the result into the 'Result'box on the focus form....essentially so I can have a play and see how it all works.
Behind the button On_Click I ve put
I get 'Argument not optional'
If I remove the ".SLAdays" I get Expected Variable or procedure error
Can someone point out where I'm going wrong please?
Also, as far as I understand, I should be able to call this Function from any form as long as there are the FromDt,ToDt and Result fields. Is that correct?
Thanks in advance