473,748 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query calculation problem

15 New Member
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 1680
missinglinq
3,532 Recognized Expert Specialist
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
jenniferhelen
15 New Member
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 Recognized Expert Specialist
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,571 Recognized Expert Moderator MVP
@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
jenniferhelen
15 New Member
Yes that makes sense. I have made those changes. Thanks again.
Apr 12 '09 #6
NeoPa
32,571 Recognized Expert Moderator MVP
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
17329
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 dateadd(year,1,dateadd(month,-1,getdate())) AND dateadd(day,-1,(dateadd(month,1,dateadd(year,1,dateadd(month,-1,getdate()))))) *************** (first part of the date calculation comes out to be '2005-05-01' and
4
2072
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 premiums are dependant on the country in which the client is in. Therefore, we have a Country table, with its list of rates, a client table and then the property table. Getting this is great, works fine, easy! Problem is, now I need to work out a...
0
1865
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 the Query calculates a field to become identical to the corresponding table field, for instance: Table 1 contains field "ID", which is WV008A00 Table 2 contains field "ID In", which is WV001000
14
2465
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 far with a loop in a form. Basically, I have key sums Current savings Current Salary Current deposit amount
8
8623
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 maybe one of you can either tell me how to get the Eval() to work or suggest and alternate method. I have a table called Units: Fields: Unit, Formula Sample Data:
5
9435
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 query it without making a table out of query 1. I can't find a median function in the "Total" field, so is there so way to make an expression to calculate the median of the orignial data from query 1 in my new query? Also, what does name by...
4
6948
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 DoCmd.OpenQuery the right one to use? it seems not work Below is the what I tried, please advice.. thanks :-) DoCmd.OpenQuery "Tuition Calculation", acViewDesign, acAdd !.Criteria = "Year=" & Year & " and Semester=" & Semester DoCmd.Save acQuery...
14
3849
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 information is coming from: tblProd with fields: item(PK), CatID(FK), List Price and other not fields not related to this question tblCat with fields: CatID(PK), Category, Tax Rate I have a query:qryListPrice with fields tblProd.ListPrice and...
3
3530
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 not a value in a table it is a calculation/expression within the query. How do I reference a query expression within an expression.
3
1598
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 more steps contained within them (substeps). I want to get a list of all of the steps in a routine, including any substeps...but excluding substeps that occur in a particular type of step ("Subroutine"). Below is a simplified example XML. The...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
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
9370
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...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
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.