DSUM problem

Access2000_JS1

Registered User.
Local time
Today, 00:18
Joined
Dec 10, 2005
Messages
24
The following statement returns NULL

Dim str As String
Dim n As Variant

str = "RemitDate >= #" & Forms![Report Menu].FromDate & "# AND RemitDate <= #" & Forms![Report Menu].ToDate & "#"
n = DSum("GSTPaid", "queryJobRemittance", str)

yet however when I run the query ie

SELECT sum(GSTPaid) FROM queryjobremittance
WHERE remitdate>=[Forms]![report menu].[fromDate] And remitdate<=[forms]![report menu].[todate];

it works fine.

The remitdate is short date,the format is dd/mm/yy, and the dsum works fine when no criteria.

Any advice will be much appreciated. Thanks.
 
How about this, IMHO:

Code:
Dim str As String
Dim n As Variant
Dim FD As Date, TD As Date

FD = Forms![Report Menu].FromDate.Value 
TD = Forms![Report Menu].ToDate.Value

str = "[RemitDate] >=  FD AND [RemitDate] <=  TD"
n = DSum("[GSTPaid]", "queryJobRemittance", str)
...
Haven't tried it myselft, hope it's the right one.
 

Users who are viewing this thread

Back
Top Bottom