473,763 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clng; Sum error "Type MisMatch"

imrosie
222 New Member
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....no t 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 5070
mlcampeau
296 Recognized Expert Contributor
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....no t 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 Recognized Expert Specialist
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....no t 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 Recognized Expert Contributor
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 New Member
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 New Member
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 New Member
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 New Member
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 Recognized Expert Contributor
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 New Member
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

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

Similar topics

1
2801
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 (0x800A000D) Type mismatch The code was var expiryDate=new Date();
8
8993
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 ************************************************************************* Error : type specifier omitted for parameter string.h line 30 ************************************************************************ The following is the line where I get this error: Line 30 : # if (_STLP_OUTERMOST_HEADER_ID == 0x269) Line 31...
4
4514
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 vbc doesn't work with error "type 'Int32' is not defined" Your help would be greatly appreciated!
1
3077
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: Private Sub Command0_Click() MsgBox MID("ABCDEFG", 1, 1)
5
4411
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 Match RE.IgnoreCase = True
0
1273
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. /manage/fiber/change.asp, line 90 line 90: RSAdd.Fields("attachment") = attachment (i am taking it to the database)
10
4582
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 4. If no match can be found, adds a new record in Table 2 and enters the ComputerID automatcially. The goal is to create a new record in Table 2 when a new record is created in table 1 and have the ComputerID fields match with a 1-to-1...
3
6794
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, linked by ClientID). When trying to open the report I receive the following error: "Data Type Mismatch in Criteria Expression" The report worked before, so as an experiment I created a new table with a structure identical to tblResult (so I...
2
5593
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 getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.