473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Clng; Sum error "Type MisMatch"

imrosie
222 100+
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....not sure why. Can anyone point me in the right direction?? thanks



Expand|Select|Wrap|Line Numbers
  1. LineTotal: Sum(CLng([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
Rosie
Aug 2 '07 #1
17 5013
mlcampeau
296 Expert 100+
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....not sure why. Can anyone point me in the right direction?? thanks



Expand|Select|Wrap|Line Numbers
  1. LineTotal: Sum(CLng([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
Rosie
My guess would be that it has to do with the CLng. Have you tried doing the Sum without it?
Maybe try it this way:
CLng(Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100))
Aug 2 '07 #2
FishVal
2,653 Expert 2GB
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....not sure why. Can anyone point me in the right direction?? thanks



Expand|Select|Wrap|Line Numbers
  1. LineTotal: Sum(CLng([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
Rosie
What is a reason for using CLng function.
BTW [Quantity]*[UnitPrice]*(1-[Discount]) will be negative when [Discount]>1
Aug 2 '07 #3
mlcampeau
296 Expert 100+
BTW [Quantity]*[UnitPrice]*(1-[Discount]) will be negative when [Discount]>1
My guess is that [Discount] is a percentage in decimal form so it probably won't ever be greater than 1. But I can't speak for imrosie, so I could be wrong
Aug 2 '07 #4
imrosie
222 100+
My guess would be that it has to do with the CLng. Have you tried doing the Sum without it?
Maybe try it this way:
CLng(Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100))
Mlcampeau,

No I will give that a try though,,,thanks

Rosie
Aug 2 '07 #5
imrosie
222 100+
What is a reason for using CLng function.
BTW [Quantity]*[UnitPrice]*(1-[Discount]) will be negative when [Discount]>1
FishVal,

No particular reason for it,,,I saw it in a book and it looked like could work for what I was trying to do. the [Discount] is for 'less than' 1 not greater than. you're right in that case, it would be negative.

Rosie
Aug 2 '07 #6
imrosie
222 100+
My guess is that [Discount] is a percentage in decimal form so it probably won't ever be greater than 1. But I can't speak for imrosie, so I could be wrong
MLcampeau,

You're so right, the [Discount] is a percentage in decimal form, it will never be greater than 1. thanks for your input. However, I just tried your suggestion, but it didn't work...

(Maybe try it this way):
Expand|Select|Wrap|Line Numbers
  1. CLng(Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100))
thanks anyway
Rosie
Aug 2 '07 #7
imrosie
222 100+
MLcampeau,

You're so right, the [Discount] is a percentage in decimal form, it will never be greater than 1. thanks for your input. However, I just tried your suggestion, but it didn't work...

(Maybe try it this way):
Expand|Select|Wrap|Line Numbers
  1. CLng(Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100))
there's no need for the extra set of paren's ....thank but it's the 'clng' it's really complaining about.
thanks anyway
Rosie
there's no need for the extra set of paren's ....thank but it's the 'clng' it's really complaining about.
thanks anyway
Aug 2 '07 #8
mlcampeau
296 Expert 100+
there's no need for the extra set of paren's ....thank but it's the 'clng' it's really complaining about.
thanks anyway
oops, didn't mean to put extra paren's in there. I was just suggesting trying to use the CLng outside of the Sum function. Have you tried summing without CLng?
Expand|Select|Wrap|Line Numbers
  1. Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
Aug 2 '07 #9
imrosie
222 100+
oops, didn't mean to put extra paren's in there. I was just suggesting trying to use the CLng outside of the Sum function. Have you tried summing without CLng?
Expand|Select|Wrap|Line Numbers
  1. Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)

Hi MLcampeau,,,,

Even with the extra paren's removed, it doesn't work, it's still complains about a type mixmatch. I think that I've got to look at the tables and figure out why summing
quantity, unit price and discount is a problem

UnitPrice = Currency
Quantity = Number
Discount = Number

Could this be the problem? thanks
Rosie
Aug 2 '07 #10
mlcampeau
296 Expert 100+
Sorry, but you still didn't answer whether you tried summing without using CLng.
Aug 2 '07 #11
mlcampeau
296 Expert 100+
are [quantity], [unit price], and [discount] in the same table?
Aug 2 '07 #12
mlcampeau
296 Expert 100+
I just made a sample table with fields Quanity: Number, UnitPrice: Currency, Discount:Number and tried
Expand|Select|Wrap|Line Numbers
  1. Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
and that worked for me. So did
Expand|Select|Wrap|Line Numbers
  1. Sum(CLng([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
so I'm not too sure why it won't work for you.
Aug 2 '07 #13
imrosie
222 100+
I just made a sample table with fields Quanity: Number, UnitPrice: Currency, Discount:Number and tried
Expand|Select|Wrap|Line Numbers
  1. Sum(([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
and that worked for me. So did
Expand|Select|Wrap|Line Numbers
  1. Sum(CLng([Quantity]*[UnitPrice]*(1-[Discount])*100)/100)
so I'm not too sure why it won't work for you.
Wow that's amazing....its in a query, one of the columns, so would that make a difference?

yes, I tried summing without the 'clng' and yes, all those variables are in the same table. That table (order details) is one of the tables in the query which has this 'sum' expression.
Rosie
Aug 2 '07 #14
mlcampeau
296 Expert 100+
Wow that's amazing....its in a query, one of the columns, so would that make a difference?
Rosie
Are you saying that you're putting the expression in the query? Because rereading my post I wasn't very clear. I made a table with those three fields, then I created a query with the expression. Are your three fields in one table?
Aug 2 '07 #15
imrosie
222 100+
Are you saying that you're putting the expression in the query? Because rereading my post I wasn't very clear. I made a table with those three fields, then I created a query with the expression. Are your three fields in one table?
Yes, the three fields are in the same table (that table is "OrderDetails" which is a part of the 'Receivables Aging query. There are 3 tables along with query called "Sum of Payments, in this whole Receivables Aging query.

thanks

Rosie
Aug 2 '07 #16
mlcampeau
296 Expert 100+
Yes, the three fields are in the same table (that table is "OrderDetails" which is a part of the 'Receivables Aging query. There are 3 tables along with query called "Sum of Payments, in this whole Receivables Aging query.

thanks

Rosie
Try specifying which table the fields belong to:
LineTotal: Sum(CLng([OrderDetails].[Quantity]*[OrderDetails].[UnitPrice]*(1-[OrderDetails].[Discount])*100)/100)
Aug 2 '07 #17
imrosie
222 100+
Try specifying which table the fields belong to:
LineTotal: Sum(CLng([OrderDetails].[Quantity]*[OrderDetails].[UnitPrice]*(1-[OrderDetails].[Discount])*100)/100)
MLCampeau,

I appreciate your sticking with me on this....I'm going off to try that now...will get back with the results..

Rosie
Aug 2 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dmgauntt2002 | last post by:
I have some javascript ASP code that sets the expiry date on a cookie to five years from now. The code worked until today, when I got the following error message: Microsoft JScript runtime...
8
by: eminemence | last post by:
Hi, I have been trying to get STLPort work for Symbian. I am using CodeWarrior compiler and it spews this errors namely *************************************************************************...
4
by: bob95226 | last post by:
Hi All, I wrote a VB.NET control in Visual Studio 2003 IDE, I am trying to re-compile it with command line compiler vbc.exe like this: vbc /t:library /out:my_control.dll my_control.vb However...
1
by: ApexData | last post by:
Access2k I WAS getting the following error when using the MID function: Run Time Error '13' Type Mismatch I have a new single form, unbound with 1-button on it that uses the following code:...
5
by: Davros9 | last post by:
Trying to get Regular Expressions working....... ---------------- Public Function SepString(InField As String) As String ''seperates on space and comma Dim RE As New RegExp Dim Matches As...
0
subashini Thiyagarajan
by: subashini Thiyagarajan | last post by:
Any one can help me in this error Error Type: Provider (0x80040E21) Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done....
10
by: dstorms | last post by:
Hi, I'm trying to create a button on a form that: 1. Takes the ComputerID from the form linked to Table 1, 2. Checks Table 2 for a matching ComputerID, and 3. Opens the query qryEditData, and...
3
by: martin DH | last post by:
I would definitely appreciate any help with this problem as soon as possible. Thanks! I have a report that should display the results of a query based on two tables (tblClient and tblResult,...
2
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.