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

Interesting query problem

Hi all,

I have a problem that I'm a little stumped by and need some help if
possible. I need to generate a report in Access 97 from 2 tables (easy
so far) but it requires a calculated date based on several factors
including whether a date is present in one of three fields.

Basically, I have 3 date fields (Award Date, RTL Date and Target RTL
Date) each of which may or may not contain a date. I need to use the
Award Date if present, if not then the RTL Date and if that's missing
then the Target RTL Date and then count X number of days forward from
that date based on a Cost field (below A then count 6 weeks forward,
below C but above C then count 8 weeks forward, etc.). If the Award
Date is present then that would be used otherwise the RTL Date and
Target RTL Date would be used to calculate an Estimated Award Date
based on other criteria.

There are a number of instances where there may be no date at all, in
which case I just want to show a basic message.

Any help would be very much appreciated.

Many thanks, Dean...

May 30 '06 #1
2 1479
ADezii
8,834 Expert 8TB
Hi all,

I have a problem that I'm a little stumped by and need some help if
possible. I need to generate a report in Access 97 from 2 tables (easy
so far) but it requires a calculated date based on several factors
including whether a date is present in one of three fields.

Basically, I have 3 date fields (Award Date, RTL Date and Target RTL
Date) each of which may or may not contain a date. I need to use the
Award Date if present, if not then the RTL Date and if that's missing
then the Target RTL Date and then count X number of days forward from
that date based on a Cost field (below A then count 6 weeks forward,
below C but above C then count 8 weeks forward, etc.). If the Award
Date is present then that would be used otherwise the RTL Date and
Target RTL Date would be used to calculate an Estimated Award Date
based on other criteria.

There are a number of instances where there may be no date at all, in
which case I just want to show a basic message.

Any help would be very much appreciated.

Many thanks, Dean...
The value of your Calculated Field will be the return value of a Public Function. The logic goes something like this, in the Calculated Field within the
QBE Grid:
CalcField:fAnyName([Award Date], [RTL Date], [Target RTL Date], _
[Cost])

The actual function would be something like this:
Public Function fAnyName(AwardDate As Date, RTLDate As Date, TargetRTLDate As Date, MyCost As Currency)

If IsNull(AwardDate) AND IsNull(RTLDate) AND IsNull(TargetRTLDate) Then
Msgbox "Some Message"
fAnyName = NULL
Exit Function
End If

If Not IsNull(AwardDate) Then
'use Awarddate in calculations
fAnyName = <RetVal>
Else 'AwardDate is Null
If Not IsNull(RTLDate) Then
'use RTLDate in calculations
fAnyName = <RetVal>
Else
If Not IsNull(TargetRTLDate) Then
'use TargetRTLDate in calculations along with the passed Cost
'Argument
fAnyName = <RetVal>
Else
fAnyName = <RetVal>
End If
End If
End If

Hopes this helps and does not confuse!!!
May 31 '06 #2
"DeanL" <de*************@yahoo.com> wrote in
news:11**********************@v35g2000cwv.googlegr oups.com:
Hi all,

I have a problem that I'm a little stumped by and need some
help if possible. I need to generate a report in Access 97
from 2 tables (easy so far) but it requires a calculated date
based on several factors including whether a date is present
in one of three fields.

Basically, I have 3 date fields (Award Date, RTL Date and
Target RTL Date) each of which may or may not contain a date.
I need to use the Award Date if present, if not then the RTL
Date and if that's missing then the Target RTL Date and then
count X number of days forward from that date based on a Cost
field (below A then count 6 weeks forward, below C but above C
then count 8 weeks forward, etc.). If the Award Date is
present then that would be used otherwise the RTL Date and
Target RTL Date would be used to calculate an Estimated Award
Date based on other criteria.

There are a number of instances where there may be no date at
all, in which case I just want to show a basic message.

Any help would be very much appreciated.

Many thanks, Dean...

This sounds like you need a user defined function more than a
query, because the logic just gets too convoluted. You can then
call the udf in the query, or in the report itself.
Off the top of my head, this should do what you want.
public function CalcDate( dtAward, DtRTL, DtEstm, AmtCost) as
variant.

If not IsNull(dtAward) then
Calcdate = dtAward
ElseIf not IsNull(dtRTL) then
Calcdate = dtRTL
ElseIf not IsNull(dtEstm) then
If Cost < A then
Calcdate = DateAdd("ww",6, dtEstm)
ElseIf Cost < B then
Calcdate = DateAdd("ww",7, dtEstm)
Else
Calcdate = DateAdd("ww",8, dtEstm)
Else
Calcdate = "No Date Available"
end function

--
Bob Quintal

PA is y I've altered my email address.
May 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Robert Smith | last post by:
I'm doing a website development course and during an exercise my teacher gave me to do at home I was confronted with errors. Surprisingly, those that did the exercise in class did not receive...
2
by: Chris Stewart | last post by:
We're having an issue here at school with trying to access a SQL Server database from a .NET application. As a department, we roll out a generic image to all of our lab computers. For some reason...
1
by: arikatla | last post by:
We are using SQL Server 2000 database (with sp3) and recently we faced an interesting issue with full text search. According to SQLServer help page "AND | AND NOT | OR Specifies a logical...
8
by: ºa¤Ö | last post by:
I find a interesting question, and I cannot solve it @.@ If i want to insert unicode data, I need using recordset.addnew instead of using "insert into table" query or "stored procedure" All...
2
by: Dylan Phillips | last post by:
A strang error is occurring when I run the following code: SqlConnection c = new SqlConnection(); c.ConnectionString = "Initial Catalog=Northwind;user id=sa;password=kat1ie;Data Source=server";...
1
by: Jay | last post by:
Hello, I have an interesting design problem, I would like to have your opinion on. I have table DRAWINGS, which has a field DrawingName which contains a list of drawings with thier full path....
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32 seconds), compute aggregate functions on the...
4
by: ward | last post by:
First off, thanks to those who assisted me with the nl2br() issue. Now here is another interesting "break." I brought up a record in my edit_task page, didn't make a change, and hit "submit." ...
4
by: Tony Toews [MVP] | last post by:
A client asked why some code behind a list box suddenly started updating 57386 records in a table instead of the expected 38 records. Turns out the problem is a difference in behavior between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
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:
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
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...
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.