Sleekmac
Registered User.
- Local time
- Today, 01:15
- Joined
- Sep 25, 2006
- Messages
- 34
Hi Folks,
I have a problem I've been mulling over, and I thought I'd just post it here and see if maybe someone has already gone through this and might be able to tell me what I am missing. I have an access database that contains a table of currency rates by forward date. So for example, there are 90+ individual currencies in column 1, with 6-10 rates for each currency, each rate corresponding to a distinct "value date". I have another column which contains a concatenation of currency and value date, and this is my primary key. (ex. AUD10/12/06, EUR10/19/06, etc.) These dates are pretty much standard, but not always consistent for each currency. They all have a S (spot) rate, and most have a 1W (1 week) rate, a 1M (1 month), 3M, 6M, and 1Y.
At one point in the process, an append query is run that adds records to the table, leaving the rate field blank. The dates that are used fall somewhere between the given rates, for example 9 days, which would be two days after 1W, but 11 days before 1M. Then, another bunch of queries determine what the "last available" rate before the target rate is, and the "next available" one after it, and use these as the two givens to figure out what the target rate would be between them. The way I have this working is not ideal, and it works so far only because the rates it is interpolating have so far been less than 1 week out, or in a few cases between 1 month and 3 months. So since the data points are typically in those ranges, I have 3 cascading queries, the first assumes the target date is between 1M and 3M, the second assumes it's between 1W and 1M, and the third assumes it's between S and 1W. Each of these assigns the respective low and high points as the "last" and "next".
What would be better, is if a bit of VBA code (or even an SQL statement) could put the dates in order for each currency, and determine what the last record up is, use that as the "last available", and set the next record down as the "next available". This has turned out to be easier said than done.
It's easy to do in Excel with activecell.offset, but I'd rather keep it all in access.
I have a problem I've been mulling over, and I thought I'd just post it here and see if maybe someone has already gone through this and might be able to tell me what I am missing. I have an access database that contains a table of currency rates by forward date. So for example, there are 90+ individual currencies in column 1, with 6-10 rates for each currency, each rate corresponding to a distinct "value date". I have another column which contains a concatenation of currency and value date, and this is my primary key. (ex. AUD10/12/06, EUR10/19/06, etc.) These dates are pretty much standard, but not always consistent for each currency. They all have a S (spot) rate, and most have a 1W (1 week) rate, a 1M (1 month), 3M, 6M, and 1Y.
At one point in the process, an append query is run that adds records to the table, leaving the rate field blank. The dates that are used fall somewhere between the given rates, for example 9 days, which would be two days after 1W, but 11 days before 1M. Then, another bunch of queries determine what the "last available" rate before the target rate is, and the "next available" one after it, and use these as the two givens to figure out what the target rate would be between them. The way I have this working is not ideal, and it works so far only because the rates it is interpolating have so far been less than 1 week out, or in a few cases between 1 month and 3 months. So since the data points are typically in those ranges, I have 3 cascading queries, the first assumes the target date is between 1M and 3M, the second assumes it's between 1W and 1M, and the third assumes it's between S and 1W. Each of these assigns the respective low and high points as the "last" and "next".
What would be better, is if a bit of VBA code (or even an SQL statement) could put the dates in order for each currency, and determine what the last record up is, use that as the "last available", and set the next record down as the "next available". This has turned out to be easier said than done.
It's easy to do in Excel with activecell.offset, but I'd rather keep it all in access.