Hi all
I need some guidance regarding this VBA Function.
I created the following function to add deduction based on these parameters. I create some variable with value to test to make sure it works, and it does. The issue is when I tested with real date in a query I was getting an error regarding a null value. Now I do not get any error while running the query, but I got #Error in the amount.
Function DeductionSum(DedEEID As Integer, BenefitID As Integer, StartDate As Date, EndDate As Date)
Dim DAmount As Double
'Dim StartDate As Date
'Dim EndDate As Date
'Dim DedEEID As Integer
'Dim BenefitID As Integer
'DedEEID = 4
'BenefitID = 1
'
'
'StartDate = #1/1/2017#
EndDate = #12/31/2017#
DAmount = (DSum("[deductionamount]", "tbpayrollDeduction", "[DeductionEmployeeID]=" & DedEEID & " AND [DeductionBenefitsID]=" & BenefitID & " AND [payDate]>= #" & Format(StartDate, "mm/dd/yyyy") & "#" & " AND [payDate]<= #" & Format(EndDate, "mm/dd/yyyy") & "#"))
I need some guidance regarding this VBA Function.
I created the following function to add deduction based on these parameters. I create some variable with value to test to make sure it works, and it does. The issue is when I tested with real date in a query I was getting an error regarding a null value. Now I do not get any error while running the query, but I got #Error in the amount.
Function DeductionSum(DedEEID As Integer, BenefitID As Integer, StartDate As Date, EndDate As Date)
Dim DAmount As Double
'Dim StartDate As Date
'Dim EndDate As Date
'Dim DedEEID As Integer
'Dim BenefitID As Integer
'DedEEID = 4
'BenefitID = 1
'
'
'StartDate = #1/1/2017#
EndDate = #12/31/2017#
DAmount = (DSum("[deductionamount]", "tbpayrollDeduction", "[DeductionEmployeeID]=" & DedEEID & " AND [DeductionBenefitsID]=" & BenefitID & " AND [payDate]>= #" & Format(StartDate, "mm/dd/yyyy") & "#" & " AND [payDate]<= #" & Format(EndDate, "mm/dd/yyyy") & "#"))