我尝试修改总查询,以便如果总和超过1000,例如它会更改2个字段中的值。例如,1000克变为1千克,反之亦然。 例如,如果我有20个以克为单位的项目,并且这20个项目的总和为1200克,那么如何将其自动更改为1.2千克。如何让它检测到超过1000,将它从克转换成千克。
答案 0 :(得分:0)
怎么样
Function presentFormattedWeight(Weight as Long) as String
Dim KgWeight as Long
Dim GramWeight as Long
KgWeight =0
if(Weight mod 1000)>0 then
KgWeight = Weight\1000
GramWeight = Weight mod 1000
else
GramWeight = Weight
end if
if KgWeight >0 then
presentFormattedWeight = KgWeight & "." & GramWeight & "Kg"
else
presentFormattedWeight = GramWeight & "grams"
end if
End Function