473,396 Members | 1,764 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,396 software developers and data experts.

Another problem with sum

I'm trying to create an extended price by making query on a form

Basically, I have
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW [Siding Details].*, ([Quantity]*[Price]) AS ExtPrice
  2. FROM [Siding Details];
My ExtPrice field is bound to ExtPrice in the table.

Another irritating problem I'm having is..

I have an AfterUpdate event with the following
Expand|Select|Wrap|Line Numbers
  1. Me.Price = Me.Product.Column(2)
  2. Me.Quantity.SetFocus
Let's say the price of the item in Product is $3.25. The price that gets generated in [Price] is $3.00. It either rounds up or rounds down the value. The [Price] field is bound to [Price] in the table.

If I simply use an expression =product.column(2) in the [Price] field it transfers the decimals correctly but I would rather not go this route as I would like to bind the field.

Hoping someone can give me a hand with these 2 issues. I've searched everywhere. I've looked in a couple other order entry test databses and copied what was done with no success. I know I must be missing something but can't figure it out.
Feb 22 '08 #1
4 1398
Stewart Ross
2,545 Expert Mod 2GB
...I have an AfterUpdate event with the following

Me.Price = Me.Product.Column(2)
Me.Quantity.SetFocus

Let's say the price of the item in Product is $3.25. The price that gets generated in [Price] is $3.00. It either rounds up or rounds down the value. The [Price] field is bound to [Price] in the table. ...
The rounding error appears to be some kind of type conversion issue. I can't think offhand of a reason why in this case, as Access usually converts 'on the fly' dependent on the calculation involved. (Bear in mind that combo boxes return text values in their columns, not type-bound values.)

On the surface, it appears that an integer conversion is taking place (hence the dropping of the decimals).

Assuming that your [price] field is either of type currency or double, try an explicit type conversion when referring to the combo column involved:

Me.Price = CCurr(Me.Product.Column(2)), or
Me.Price = CDbl(Me.Product.Column(2))

This will at least ensure that [price] is fed with a value of the correct type, which can only help in eliminating possible causes of the error.

Regards

Stewart
Feb 24 '08 #2
Me.Price = CCurr(Me.Product.Column(2)) didn't work at all and cause the debugger to pop up.

Me.Price = CDbl(Me.Product.Column(2)) just gave me the same results I was getting previously
Feb 25 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Me.Price = CCurr(Me.Product.Column(2)) didn't work at all and cause the debugger to pop up.

Me.Price = CDbl(Me.Product.Column(2)) just gave me the same results I was getting previously
OK. Going back to the SELECT statement in your original question, you said this was the code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT DISTINCTROW [Siding Details].*, ([Quantity]*[Price]) AS ExtPrice
  3. FROM [Siding Details];
  4.  
Is what you are doing that you are:
1. using a userform to select a price from a combo box, which is bound to the Price field (presumably so that you can enter and vary a price value for a customer on demand)
2. after entering the price, your user then enters a quantity,
3. then you calculate an ExtPrice using the Select statement?

I am not clear as to why you would do this, as you could have a calculated control on your form which does this for you. Anyway, I would ask you to clarify that I have interpreted this correctly?

It is important, because if [Price] is a double there will be no decimal truncation involved if you explicitly type-convert the combo result feeding it to double. Also, if ExtPrice and Price are doubles then [Quantity] * [Price] will generate a double as a result, not an integer value.

Please confirm the types of [price] and [ExtPrice] in your underlying table. I would also like to see the SQL code for your combo box, to try to resolve this one fully if possible.

Regards

Stewart
Feb 25 '08 #4
NeoPa
32,556 Expert Mod 16PB
I suspect [Quantity] is an integer field. Try casting that to Double in the SQL.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW [Siding Details].*, (CDouble([Quantity])*[Price]) AS ExtPrice
  2. FROM [Siding Details]
Feb 25 '08 #5

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

Similar topics

2
by: luu duong | last post by:
I know this is probably easy but here is the details. I have an asp page that is not inside a frameset. I want to post data to another asp page that is inside a frameset. So firstpage.asp has...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
1
by: SC G | last post by:
Hi, I use a web application that has 120 checkboxes on it for me to select from before I submit a form. I have to select boxes in groups of 40 (1-40,41-80,81-120). Each submission generates a...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
26
by: Paul | last post by:
public class A { public A () { // here I would like to call the second version of _ctor, how to accomplish this ? } public A (int a, int b, int c) {
3
by: Kathy Burke | last post by:
Hi, I'm tired, so this question may be silly. I have a fairly long sub procedure. Based on one condition, I load another sub with the following: If Session("GRN") = "complete" Then txtScan.Text...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
4
by: ejswanson | last post by:
I need to have a button on a web page that posts information contained on this page to another web page on a completly separate site? How do I accomplish this? Thanks Eric
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.