Hi
I would really appreciate some help. I'm not very good at Access and right now I have to make an Database for part of an Internship project. So this Q might seem silly to you but I really don't know hoz to proceed!
I've got a table with products and their prices, however the prices changed recently and from one exact date to another they should show this on my table.
The product numbers haven't changed however. If there some function like the IIf function which supports 2 parameters?
Thanks in advance!!!
15 5109
Hi
I would really appreciate some help. I'm not very good at Access and right now I have to make an Database for part of an Internship project. So this Q might seem silly to you but I really don't know hoz to proceed!
I've got a table with products and their prices, however the prices changed recently and from one exact date to another they should show this on my table.
The product numbers haven't changed however. If there some function like the IIf function which supports 2 parameters?
Thanks in advance!!!
So is this a MySQL question or an Access question since you said you are not good at access.
If it is MySql you can use - IF(condition, true, false)
.See mysql documentation.
If it is Access then you use - IIF(condition, true, false)
. See Access Online.
So is this a MySQL question or an Access question since you said you are not good at access.
If it is MySql you can use - IF(condition, true, false)
.See mysql documentation.
If it is Access then you use - IIF(condition, true, false)
. See Access Online.
And now this lies in the Access forum
Hi
Yes but I can only unsthe IIF Function for one parameter. The thing is, i need something which says: iif delivery date>31.06.07 and productnumber is 789456-123, then 400$, if delivery date <31.06.07 and productnumber 789456-123 then 450$.
Thanks already for your help!
Hi
Yes but I can only unsthe IIF Function for one parameter. The thing is, i need something which says: iif delivery date>31.06.07 and productnumber is 789456-123, then 400$, if delivery date <31.06.07 and productnumber 789456-123 then 450$.
Thanks already for your help!
So why not use -
-
if (deliverydate >) 31.06.07 and (productnumber = 789456-123) then
-
retval = 400
-
elseif (deliverydate < 31.06.07) and (productnumber = 789456-123) then
-
retval = 450
-
end if
-
Hi
Yes but I can only unsthe IIF Function for one parameter. The thing is, i need something which says: iif delivery date>31.06.07 and productnumber is 789456-123, then 400$, if delivery date <31.06.07 and productnumber 789456-123 then 450$.
Thanks already for your help!
You could use nested iifs. -
iif([Delivery Date] > #31/06/07#, iif([ProductNumber] = 789456-123, 400$, 0$),iif([ProductNumber] = 789456-123, 450$, 0$))
-
You could use nested iifs. -
iif([Delivery Date] > #31/06/07#, iif([ProductNumber] = 789456-123, 400$, 0$),iif([ProductNumber] = 789456-123, 450$, 0$))
-
Hi
The thing is, all my products have new prices. is there a possiblity of saying iif (d.d > 31.06.07, "new_price", "old price") if i have the old and new prices in a related table?
Thanks!
The thing is, all my products have new prices. is there a possiblity of saying iif (d.d > 31.06.07, "new_price", "old price") if i have the old and new prices in a related table?
Well, I suppose the performance might be abysmal, but you could create a function in VBA which looks up the appropriate price, then just call that function in your query.
So instead of building an elaborate IIF() setup, you'd just use something like PriceAsAtDate(DateField, ProductField).
Depending on the size and volatility of the data, it might be worth caching in an array or something, to speed up these lookups.
Yes, you can have it return the values of another table. You'd simply have to switch the values with the field names of the new and old prices. If your tables are properly related everything should match up just fine.
Yes, you can have it return the values of another table. You'd simply have to switch the values with the field names of the new and old prices. If your tables are properly related everything should match up just fine.
Yes but the thing is I still need the old prices. I have to give out warranty claims and for older orders the warranty claim should match up with the old price.
Yes but the thing is I still need the old prices. I have to give out warranty claims and for older orders the warranty claim should match up with the old price.
It seems as though it should be possible to use some sort of aggregate function or something, to retrieve the first record which matches one field and is equal to or less than another field.
Bear with me, I'm just thinking out loud, here...
If your lookup table had a field which had the product ID (forget what it's called) and the date combined, then all you'd need do is find the first record in sequence, starting from Product&Date, sorted descending.
I'm going to see whether I can get some real Access gurus to pop in, as I'm getting out of my depth.
NeoPa 32,556
Expert Mod 16PB
Killer's on the right lines here.
You need to separate out the products from the prices. Prices need to be dated so something like : Table Name=tblProduct - Field; Type; IndexInfo
-
ProdID; Autonumber; PK
-
ProdDesc; String
-
... Other product specific info
Table Name=tblProdPrice - Field; Type; IndexInfo
-
ProdPriceID; Autonumber; PK
-
ProdID; number; CFK (part of compound key)
-
PriceDate; Date/Time; CFK
-
Price; Numeric
Link in the two tables on [ProdID] and select only the dates you want in your WHERE clause.
And presumably you can use a <= operator in the WHERE clause. Requiring an exact match wouldn't be much help.
But, how would you ensure that you got the latest as at that date? In other words, let's say the price has changed five times. For a given date, you would need the last price set on or before that date, but not the earlier ones. How would you specify, in SQL, that you want the first (or last) value in the key range? This is what stumped me.
NeoPa 32,556
Expert Mod 16PB
Use the WHERE clause to exclude any after the date you want then use the Max() aggregate function to select the most appropriate record from those that are left.
Use the WHERE clause to exclude any after the date you want then use the Max() aggregate function to select the most appropriate record from those that are left.
Ahah! Max() is what I was thinking of. I knew there was something that would do it. Thanks, NeoPa.
NeoPa 32,556
Expert Mod 16PB
No probs Killer :)
I should have mentioned (for Joe Public) that the GROUP BY clause is also required, but I'm sure you don't need telling that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Isaac |
last post by:
Alan Isaac wrote:
> Default parameter values are
> evaluated once when the function definition is
> executed. Where are they stored? ... Where is this documented?
Forgive any poor phrasing: I'm...
|
by: John Miles |
last post by:
Hi --
This is a bit of an implementation-specific problem, but I'd like to
post it here to see if there's a general answer within the auspices of
the language.
I'm developing a high(er)-level...
|
by: BRG |
last post by:
I know that default template arguments cannot be used in function
templates but are default function parameters legal?
That is, is this:
----------------------------------
#include <functional>...
|
by: Marlene Stebbins |
last post by:
I am experimenting with function pointers. Unfortunately, my C book has
nothing on function pointers as function parameters. I want to pass a
pointer to ff() to f() with the result that f() prints...
|
by: Martin Dařílek |
last post by:
Hi all,
please can You help me with translation of function parameters provided by
p2smon.dll library (Crystal Reports)? Any example, which I found, is only in
VB (I don't like it :-)
I would...
|
by: Iker Arizmendi |
last post by:
How are function parameters of rowtype specified when
calling them from a client such as libpq? Is there a syntax
similar to that for arrays? (eg, {x, y, z} )
Thanks,
Iker
...
|
by: utab |
last post by:
Hi there,
Is there a way to convert a double value to a string. I know that there
is fcvt() but I think this function is not a part of the standard
library. I want sth from the standard if...
|
by: Jason |
last post by:
Hello:
First, if this is one of those "questions asked a million times" just say so
and I'll dig a little deeper. If not, then...
I'm curious, is it typical to use member data (properties,...
|
by: lovecreatesbea... |
last post by:
Shoud we declare non-pointer function parameters with const keywords?
int main(void){
int f(const int i);
int i;
f(i);
return 0;
}
|
by: =?ISO-8859-15?Q?Jean=2DFran=E7ois?= Lemaire |
last post by:
Hello,
I'm having a discussion with someone who sustains that function
parameters, when they are smaller than an int (say short or char) are
automatically promoted to int before being passed to...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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: 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...
| |