473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If Then Statement Help

12 New Member
What I am looking to do is create an if then statement for a particular access query, here are the facts

Tables used
Mainframe Report List

Fields Within the table that are used for the if then statement
GENERATIONS
FREQUENCY
EXTENDED

what i would like is to say if FREQUENCY = Daily5 then Divide value in GENERATIONS by 5 and Place the Result in EXTENDED ELSE IF FREQUENCY = WEEKLY then Divide value in GENERATIONS by 1 etc etc for the following values

Daily5
Daily7
Weekly
Monthly
Quarterly
Annualy
On Demand


ELSE IF NULL then EXTENDED = NULL
Any help on this would be greatly appreciated as this has a deadline of tomorrow morning :( Thanks
Jun 12 '07 #1
1 1719
ADezii
8,834 Recognized Expert Expert
What I am looking to do is create an if then statement for a particular access query, here are the facts

Tables used
Mainframe Report List

Fields Within the table that are used for the if then statement
GENERATIONS
FREQUENCY
EXTENDED

what i would like is to say if FREQUENCY = Daily5 then Divide value in GENERATIONS by 5 and Place the Result in EXTENDED ELSE IF FREQUENCY = WEEKLY then Divide value in GENERATIONS by 1 etc etc for the following values

Daily5
Daily7
Weekly
Monthly
Quarterly
Annualy
On Demand


ELSE IF NULL then EXTENDED = NULL
Any help on this would be greatly appreciated as this has a deadline of tomorrow morning :( Thanks
In my opinion, this can only be done in code and I have posted the partial solution and logic below:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  2.  
  3. Set MyDB = CurrentDb()
  4. Set MyRS = MyDB.OpenRecordset("Mainframe Report List", dbOpenDynaset)
  5.  
  6. MyRS.MoveFirst
  7.  
  8. Do While Not MyRS.EOF
  9.   MyRS.Edit
  10.     Select Case MyRS![FREQUENCY]
  11.       Case "Daily5"
  12.         MyRS![EXTENDED] = MyRS![GENERATIONS] / 5
  13.       Case "Weekly"
  14.         'Here is where I get confused...
  15.       Case Else
  16.         MyRS![EXTENDED] = Null
  17.     End Select
  18.   MyRS.Update
  19.     MyRS.MoveNext
  20. Loop
  21.  
  22. MyRS.Close
This is where I totally got confused. You'll have to fill in the missing code yourself.
IF FREQUENCY = WEEKLY then Divide value in GENERATIONS by 1 etc etc for the following values

Daily5
Daily7
Weekly
Monthly
Quarterly
Annualy
On Demand
Jun 14 '07 #2

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

Similar topics

3
6231
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Syntax error in UPDATE statement. /polyprint/dataEntry.asp, line 158
4
3276
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant section from the manual: 20.1.9.7 WHILE Statement
2
2362
by: Little PussyCat | last post by:
Hello, I hope you can help me. We have a SQL Server 2000 database at work, (which works with a VB6 frontend) which grew to a considerable size, so one of my past colleagues sent me this truncate statement to use on the database. I ran it like this, and all appeared to be well, it shrank the database, Shortly afterwards, after I ran this I noticed something not quite right. for example, one of the tables we keep is a User_Admin table...
5
3505
by: WindAndWaves | last post by:
Hi Team The function below searches all the tables in a database. However, if subsearch = true then it searches all the objects listed in a recordset (which are all table names). I thought to be really clever and use : #if subsearch ... #else ..... #end if
11
2213
by: Scott C. Reynolds | last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for truth and execute those statements, such as: SELECT CASE True case x > y: dosomestuff() case x = 5: dosomestuff() case y > x: dosomestuff()
10
2370
by: John Smith | last post by:
Can you do a Select Statement within a Select Statement? I want to build a query similar to queries built in Access which link to other queries but using only SQL Statements. Is it possible? If so, how do you do it? Thanx in adv.
6
2691
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the person wants to receive a newsletter and 0 no, don't want to receive it. Now.....when trying to create an UPDATE statement I am running into problems writing the code for it. I had issues before with missing commas but now that the commas are there...
4
5606
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" & request.form(strSerialNum) & "', " sql01 = sql01 & "Description = '" & request.form(strDesc) & "', " sql01 = sql01 & "Location = '" & request.form(strLoc) & "', "
7
2702
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
18
7979
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
0
9685
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
9537
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,...
1
7560
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
6803
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
5459
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
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
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
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.