DSUM value Return as string

Shafique

Board Regular
Joined
Nov 23, 2018
Messages
119
HI EVERYONE.
in my query i set a field as USED30 where i get last 30 days used weight.
my table name is IMPPRD
[REELWEIGHT] as number
[REELCOLOR] as short text

but the DSUM Function's value Return as string
WHY......
 

Attachments

  • DSUM IN QUERY.jpg
    DSUM IN QUERY.jpg
    65 KB · Views: 19
  • QUERY RESULT.jpg
    QUERY RESULT.jpg
    21.7 KB · Views: 15

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Your syntax is wrong.
Look at the difference you have between the date -31 and date + 1
Put all that into a string variable in the immediate window then debug.print it to see what you actually have, NOT what you think you have.
AFAIK DSum() cannot return a string? That woul make no sense whatsoever.
 
Upvote 0
Well I stand corrected. :)
I just tried this
Code:
SELECT tblBoxID.BoxID, tblBoxID.PackedQty, DSum("PackedQty","tblBoxID","ID > 20") AS Expr1, VarType([EXpr1]) AS Expr2
FROM tblBoxID;
and the vartype was 8, which is a string.?

However you can easly add a numeric to it and it does not fall over, so for all intents and purposes it is numeric.?
 
Upvote 0
The return value of DSum is a variant, so I suppose the data type of the returned value could be anything, including Null.
 
Upvote 0
The return value of DSum is a variant, so I suppose the data type of the returned value could be anything, including Null.
I added VAL and Nz function to this formula and all was well..
THANKS for your Valuable time

;)USED30: Val(Nz(DSum("REELWEIGHT","IMPPRD","[REELCOLOR]='" & [RCOLOR] & "' AND [PRDATE]> # " & Date()-31 & "# AND [PRDATE]< # " & Date() & "#+1"),0))
 
Upvote 0
I think we established that the result was text because one of the inputs is text (RCOLOR). Based on the limited data you show it looks like it's numeric so why is it text (or did you manually left justify the field)? Also wondering why you use Val function for this because you don't seem to get a mix of numbers and text in the calculated result. If you want the calculation to be number data type, why not use a type conversion function such as CLng or Cint instead? You would be wise to use NZ function inside of that if a calculated result could be null.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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