473,407 Members | 2,598 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,407 software developers and data experts.

query calculation problem

I am having a problem with a calculation in Microsoft Access. I am trying to add two numeric columns, however the result I am receiving is the data is being concatenated. I am using the following formula: newField:([field1]+[field2]). If field1 contains 567 and field2 contains -98, my result is 567-98 instead of 469. I have performed simular calcualtions many times and I am going nuts trying to figure out why this won't work. I appreciate any help you can provide.
Apr 5 '09 #1
6 1666
missinglinq
3,532 Expert 2GB
I reproduced your scenario, and this will only happen if you have Field1 and Field2 defined as Text. If they're defined as Numbers you'll get your desired results.

Alternatively, you could use

NewField: Val([Field1]) + Val([Field2])

Welcome to Bytes!

Linq ;0)>
Apr 6 '09 #2
Thank you, thank you, thank you! I don't even want to tell you how much time I spent on that!

Just out of curiosity, the fields are listed as "numbers" in the original table. However I have them in initial query before appearing in the final query where I am performing the calculations. Does the format not carry over from the table? Also, in the query I tried changing the format to "general number" or "standard number" and had the same concatenating result.

I really appreciate your help.
Apr 6 '09 #3
missinglinq
3,532 Expert 2GB
Don't really know where they got changed to Text, although the output of most formatting does is string/text rather than the original datatype.

Linq ;0)>
Apr 6 '09 #4
NeoPa
32,556 Expert Mod 16PB
@jenniferhelen
This is where the problem is introduced.

The Format() function returns a string value, not a numeric value simply displayed as formatted. It is not generally considered a good idea to convert the value to a formatted string until it is necessary (If reporting, format it in the report rather than any of the intervening steps).

Does that make sense?

Welcome to Bytes!
Apr 6 '09 #5
Yes that makes sense. I have made those changes. Thanks again.
Apr 12 '09 #6
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it JH :)

Good luck with your project.
Apr 12 '09 #7

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

Similar topics

1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
0
by: leavandor | last post by:
I am trying to design a query that works with a relationship between a Table and a Query. I am comparing a value in the table with a computed value inside the query. The reason for this is that...
14
by: Crimsonwingz | last post by:
Need to calculate a sum based on a number of factors over a period of years. I can use formula ^x for some of it, but need totals to carry over in the sum and have only been able to do this thus...
8
by: Bri | last post by:
Greetings, I am using Eval() in a query with only limited success. If the text within the function contains a reference to a Field I get #ERROR#. I'll try and explain what I'm trying to do and...
5
by: jonm4102 | last post by:
I'm trying to calculate the median of some numerical data. The data can only be found in a query (henceforth query 1) field I previously made, and I would prefer to calculate the median in a new...
4
by: anniebai | last post by:
I have a query named "Tuition Calculation" saved in the database. In the code, the criteria of the query need to be added/modified and be saved for use of another auto-generate report. Is...
14
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database for inventory control. I am setting up a form (frmProducts) for the viewing and adding of product information. I have several tables that this...
3
by: mbardwel | last post by:
I am building a query in Access 2003. Here is my problem. I create an expression called SUN_ST In a later expression I reference a calculation based on SUN_ST ie, MON_ST=sum-SUN_ST SUN_ST is...
3
by: oopsatwork | last post by:
I'm trying to construct an XPath and it is giving me trouble. I have an XML that contains a "Routine". The routine contains "Steps". The steps have different types. Some types of steps have...
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
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: 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
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...
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.