DSUM Result comes as String

Shafique

Board Regular
Joined
Nov 23, 2018
Messages
119
MTIN: DSum('QTY',"INKIN","[IDATE] <#" & Date() & "#+1 AND [IDATE] >#" & DateSerial(Year(Date()),Month(Date()),1) & "#-1 AND [INKNAME]='" & [CHAMICALBAL]![INKNAME] & "' AND [MADE]='" & [CHAMICALBAL]![MADE] & "'")
this is formula for current month's Total.
Why it Comes as String in query Builder
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    79.6 KB · Views: 32

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Just a guess, but I'll say it's because QTY field is text. Either that, or for some records the return is Null thus the value type is a variant. When variants are encountered, Access determines what the value type should be. Perhaps this causes records with values to default to string, since one field record in the query cannot be a number, the next a variant and so on. It's noteworthy that the first few records are null, which is probably what makes the decision about data type right away. You could experiment with table copies and make those nulls go away and see what happens.

You might try wrapping the whole thing in a type conversion function, such as CLng.
 
Upvote 0
I get type mismatch if I try your syntax where the +1 is outside the # marks.

Code:
? "#" & date() +1 & "#"
#23/04/2024#
 
Upvote 0
I get type mismatch if I try your syntax where the +1 is outside the # marks.

Code:
? "#" & date() +1 & "#"
#23/04/2024#
MTIN: DSum('QTY',"INKIN","[IDATE] <#" & Date()+1 & "# AND [IDATE] >#" & DateSerial(Year(Date()),Month(Date()),1)-1 & "# AND [INKNAME]='" & [CHAMICALBAL]![INKNAME] & "' AND [MADE]='" & [CHAMICALBAL]![MADE] & "'")

same results
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    96.6 KB · Views: 19
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top