473,505 Members | 13,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing Two Fields Within the Same Table

2 New Member
I have a database of rents for all of my company's offices. I want to create a query that shows when there is an increase or decrease.

I would like a returned phrase like INCREASE, DECREASE, SAME, or STOPPED when the query runs.

I have tried many different codes and none worked with error messages such as bad syntax and etc.

Thank you for any and all help.
Jul 29 '15 #1
5 3576
Seth Schrock
2,965 Recognized Expert Specialist
Assuming that you are wanting to compare two fields in the same record, you could use the Switch function either in a query or in a textbox's control source.
Expand|Select|Wrap|Line Numbers
  1. Switch(Field1 > Field2, "Increase", Field1 = Field2, "Same", Field1 < Field2, "Decrease", Field1 Is Null, "Stopped")
Jul 29 '15 #2
Rabbit
12,516 Recognized Expert Moderator MVP
If you are not talking about two fields in the same row, then you have not given us any information about your data and how it's structured and we can't help you without that. All we can say is join the table to itself to get your two related rows together.
Jul 29 '15 #3
NeoPa
32,557 Recognized Expert Moderator MVP
I would guess that Rabbit has this right Kim.
You need to give us the full question with the basic details if you want us even to be able to help you.

We want to, but you need to ensure we have the basics at least in order to be able to.
Jul 30 '15 #4
KimE
2 New Member
Yes, the fields are in the same row. The column headers are the months and year (AUG-2015, SEP-2015, etc) and the first cell of each row is the office name.

I hope this helps.
Aug 3 '15 #5
Seth Schrock
2,965 Recognized Expert Specialist
Then my solution in post #2 would work. However, it seems like your database isn't normalized. Problems like this become a whole lot simpler in a normalized database. See Database Normalization and Table Structures.
Aug 3 '15 #6

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

Similar topics

6
8321
by: Jason | last post by:
I need to populate a table from several sources of raw data. For a given security (stock) it is possible to only receive PARTS of information from each of the different sources. It is also...
1
4819
by: Chris | last post by:
I have the following table structure. group1 group2 group1_result group2_result 'One' 'Two' 3 2 'One' 'Two' 3 1 'One' 'Two' 2 5 'One' ...
2
21561
by: cyder | last post by:
Hi All I want to create a filter that will detect whether I have the same value in say field 3 and field 4. Could you please tell me how to do this? Thanks Cydernet
4
1857
by: jean.ockert | last post by:
Greetings. Access version 2003 on an XP system I am using the template "Event Management" database as the primary database and need additional functionality added. I have a dance studio. ...
1
1762
by: swtrader | last post by:
I need to find the earlier of two separate dates in the same table and populate a field in the same table with the earlier date.
0
1641
by: khoegen | last post by:
Folks, I am in the process of designing a database, within which I have created a table called "tblDOCUMENTS". As the title suggests, this is a list of documents (records) of varying types. I...
2
3306
by: sudhaMurugesan | last post by:
Hi, I have a table like this. IOMode Date EmployeeID EmpName O 2007-02-28 16:46:00.000 FI0001258 M.MANIGANDAN I 2007-02-28...
3
1580
by: nsymiakakis | last post by:
Hello everyone, is it possible to have one form field entry populate two different field in the same form. i.e. Date field of form inputting 5/4/07 and this going to Date field on table with...
1
1783
by: cronk005 | last post by:
I am fairly new to Database creation and have devised a nice database which does what I am hoping to do. Though I am sure there is an easier way of accomplishing many of the tasks I have done, as I...
2
2057
by: peterbata | last post by:
Table looks like this: custno custname qty active banner My simple query so far looks like this: /****** Script for SelectTopNRows command from SSMS ******/ SELECT ALL , ,
0
7098
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
7366
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...
1
7017
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
7471
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...
1
5026
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...
0
4698
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...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
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 ...

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.