473,769 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems creating "if then" in an Access Query

1 New Member
After all is done, I want query(s) which will give me the ability to create a report which will allow me to compare 3 apts with the parameters equaling bedroom size, and rents which are equal or greater to the tenant's current rent and bedroom size.


The first problem: Creating a field which will output a result which is contingent to what was inputed on the Bedroom Size. The apt.bedx is the cost of the rent.

(spelled out for one field)
Expr1
If the field tenant.Bedroom_ size = "0" then output field apt.bed0
If the field tenant.Bedroom_ size = "1" then output field apt.bed1
If the field tenant.Bedroom_ size = "2" then output field apt.bed2
If the field tenant.Bedroom_ size = "3" then output field apt.bed3
If the field tenant.Bedroom_ size = "4" then output field apt.bed4

(spelled out for a different query)
The second problem: Creating a field which would compare the results from the previous expr and output the results.
Expr2
tenant.gross rent <= Expr1

[Email Removed]
Apr 27 '07 #1
1 1807
MMcCarthy
14,534 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. ColumnName:
  2. IIf([tenant].[Bedroom_size] = "0",[apt].[bed0],
  3. IIf([tenant].[Bedroom_size] = "1",[apt].[bed1],
  4. IIf([tenant].[Bedroom_size] = "2",[apt].[bed2],
  5. IIf([tenant].[Bedroom_size] = "3",[apt].[bed3],
  6. IIf([tenant].[Bedroom_size] = "4",[apt].[bed4],0)))))
(spelled out for a different query)
The second problem: Creating a field which would compare the results from the previous expr and output the results.
Expr2
tenant.gross rent <= Expr1
I don't understand the logic of what you are asking here.
Apr 27 '07 #2

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

Similar topics

9
4401
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit,...
3
1766
by: Chris Tilley - HPC:Factor | last post by:
Hi, I'm utterly confounded by this one. There must be some sort of rule that I don't know of. I'd consider myself a Newbie+1, so be gentle. I have a database connection (working A-Ok) and a Query String value from a form (passed using GET & working Ok). The server is IIS5. What I'm trying to do is get a simple IF statement to work accross the two numeric values. Once from a database and one from a Query String.
40
3044
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
145
6344
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two programs: /*** a.c ***/
35
2738
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And I'm pretty sure the rest of the program is working just fine. The only thing I could think might be wrong is that the if statement can only hold so many values in itself? Let me show what I'm doing: if (table001]>>5]&b&0x1f] != 0 &&
12
20703
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
37
3984
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as a function
3
3164
by: ARC | last post by:
I'm having trouble here with Access 2007 and connecting to a different database. The code below works great IF the previous back-end database connection is still present and you are trying to connect to a new location (ie: datapath variable below). However, if you remove or even rename the old database, then launch your program, the code fails on the mytable.refreshlink line with an error 3044. (Description of that error is: 'C:\pc
10
2528
prn
by: prn | last post by:
I have some inherited code that I don't understand properly. It involves sending email from Access using OLE and Outlook. I've stripped it down to the relevant bits here. Specifically, the construction that (I know that) I don't understand is this: #If OutlookEnabled Then Dim olApp As Outlook.Application Dim olNewMaiItem As MailItem Set olApp = CreateObject("OutLook.Application") MsgBox "olApp created...
0
9586
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
9423
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
10043
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
7406
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
6672
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
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
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
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
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.