Dsum Syntax Help

Drand

Registered User.
Local time
Today, 21:11
Joined
Jun 8, 2019
Messages
179
Hi all

I have a Dsum calculation as follows:

JanCofAct = Nz(DSum("[CostIncGST]", "QryStockOutThisYearForBudget", "[Grp] = 'Coffee' and MonthName = 'Jan'"), 0)

I need to add a year criteria where MyYear (as an integer) is derived from a user input box when the form loads.

So what I am trying to achieve is

JanCofAct = Nz(DSum("[CostIncGST]", "QryStockOutThisYearForBudget", "[Grp] = 'Coffee' and MonthName = 'Jan'"), 0) and MyYear = the inputbox result
but I do not know the correct syntax for this.

Would appreciate your assistance

Many thanks
 
Hi. Just a guess, but maybe you could try something like:
Code:
JanCofAct = DSum("[CostIncGST]", "QryStockOutThisYearForBudget", "[Grp] = 'Coffee' And MonthName = 'Jan' And MyYear=InputBox(Enter Year)")
Hope that helps...
 
Dim lngYear As Long
lngYear = Val(InputBox("Enter Year", , Year(Date)))
JanCofAct = DSum("[CostIncGST]", "QryStockOutThisYearForBudget", "[Grp] = 'Coffee' And MonthName = 'Jan' And [Year] = " & lngYear)
 

Users who are viewing this thread

Back
Top Bottom