Form / Dsum problem (1 Viewer)

Robkbangor

New member
Local time
Today, 09:54
Joined
Nov 13, 2012
Messages
3
Hello all!

I've not been able to find anything in the forums to solve this specific problem, but apologies if it has already been covered.

I have a form with two fields, Combo25 used to choose month (as a no between 1 and 12) and YearCombo to year (2012, 2013, etc). I have another field which shows the total of a number (JobSize) specified in records from the query "Completed MRE". To do this, I have bound the field to a Dsum statement which reads as follows:

=DSum("[JobSize]","CompletedMRE","[DateCompleted] >= #01/" & getmonthno(Combo25.Value) & "/" & YearCombo.Value & "# AND [DateCompleted] <= #" & DateSerial(YearCombo.Value,getmonthno(Combo25.Value)+1,0) & "#")

It seems to work apart from one annoying thing - There are two dummy records in the query it looks at, and they both have dates for DateCompleted in November, 2012. If you set the fields on the form for Nov, 2012 it adds them up fine. But it seems to add them up for December 2012 too. All other months (past or future) are fine. It's driving me insane.

Could somebody give me any idea as to why this is happening? Any help would be greatly appreciated

Nb. I am in the UK and so the date format is set to dd/mm/yyyy

Thanks

Rob.
 

Robkbangor

New member
Local time
Today, 09:54
Joined
Nov 13, 2012
Messages
3
Hi All,

I've resolved this now - I approached it slightly differently and used the following formula instead which works perfectly.

=DSum("[JobSize]","CompletedMRE","Month([DateCompleted]) = " & getmonthno(Combo25.Value) & " And Year([DateCompleted]) = " & YearCombo.Value)

Rob
 

MStef

Registered User.
Local time
Today, 09:54
Joined
Oct 28, 2004
Messages
2,251
Look at Access help about DSum function.
(Word, Zip).
 

Attachments

  • DSum function.zip
    72.9 KB · Views: 78

Users who are viewing this thread

Top Bottom