473,396 Members | 1,726 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,396 software developers and data experts.

Would this Be an IIF Statement or?

6
Hi again everyone,

I'm new to VBA but willing to try

I have two tables that my query is looking at.

1. tblProgramActByDay
And the other is:
2. tblProgramByProductByDay

I’m trying to tell the query to
A: Look in the Program ID Field
B: if the Program ID Field = 1667100
C: Go to the table tblProgramByProductByDay

---- In that table look for the criteria---

The Field Program ID must = 0
The Field Product ID must = 38648800
The Field Locale must = en_US
The Field Report_Date must = The Current Month

If it does

Total the amount in the Sales Field from the table tblProgramByProductByDay

If not

Take the total sales for the current month from the table tblProgramActByDay
Nov 2 '06 #1
4 1347
NeoPa
32,556 Expert Mod 16PB
I'm sure help will be forthcoming if you post in here which fields are from which tables.
Nov 2 '06 #2
Corey
6
A: Look in the Program ID Field "From tblProgramActByDay Table"
B: if the Program ID Field = 1667100 "From tblProgramActByDay Table"

C: Go to the table tblProgramByProductByDay

---- In that table look for the criteria---

The Field Program ID must = 0 "From tblProgramByProductByDay Table"
The Field Product ID must = 38648800 "From tblProgramByProductByDay Table"
The Field Locale must = en_US "From tblProgramByProductByDay Table"
The Field Report_Date must = The Current Month "From tblProgramByProductByDay Table"
Nov 2 '06 #3
NeoPa
32,556 Expert Mod 16PB
Is there a relationship between the tables? Such that a field (or set of fields) in tblProgramActByDay must be equal to a field (or set of fields) in tblProgramProductByDay?
Nov 2 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Try this:

SELECT [Program ID], Sum(nz([Sales],0)) As TotalSales
FROM tblProgramByProductByDay
WHERE [Program ID] = 0
AND [Product ID] = 38648800
AND [Locale] = 'en_US '
AND Month(Report_Date) = Month(Date()
AND Year(Report_Date) = Year(Date();
UNION
SELECT [Program ID], Sum(nz([Sales],0)) As TotalSales
FROM tblProgramActByDay
WHERE [Program ID] <> 1667100
GROUP BY [Program ID];
Nov 7 '06 #5

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

Similar topics

4
by: Greg Ofiesh | last post by:
Anyone who can help, I have two tables T1 and T2. T1 has fields K1 and F2 and T2 has fields K2 and F1. F1 is the foreign key relating to K1 and F2 is the foreign key relating to K2. My...
5
by: Steve | last post by:
Hello, I've been a PHP programmer for a number of years and have just started to learn JS. My Employer (a water analysis lab) wants what should be a very simple .js written that basically takes...
6
by: JS | last post by:
In this sample code: if(n==0&&args>1){ for(i=num;args>i+1;i++){ s.length = 0; opt = document.createElement('OPTION'); s.appendChild(opt); opt.value = ""; opt.text = "\74-- Vælg --"; }
5
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...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
7
Coldfire
by: Coldfire | last post by:
i am having error ....details are ASP.Net application...in which I have a textbox <asp:TextBox ID="Other" TextMode=SingleLine CssClass="serviceBox" Width="250" Height="45" Runat="server"...
18
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...
3
by: Eric Davidson | last post by:
DB2 9.5 I keep geting the message. SQL0101N The statement is too long or too complex. SQLSTATE=54001 When one of my sql statements takes over 60 seconds to compile the sql statement. Is...
5
by: Damodhar | last post by:
When would you use an abstract class and when an interface? whats the abstract class.? please give me the sample .
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.