473,803 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forward Reference Calculation Problem?

Hello

My MainForm manages Employee records. I have created another form that
manages employee promotions. On the MainForm a button launches the
PromotionForm and lists the promotions for the employee shown on the
MainForm. The buttons clickevent looks like this: DoCmd.OpenForm
stDocName, , , "EMPID = " & Me.txtEMPID

The results are FILTERED. The Form is Continuous.
Fields are: (EmpID) (Rank) (PromoDate) and UnboundTxtBox:
(TimeInGrade)
I have placed a UnBound TextBox in the PromotionsForm called
(TimeInGrade) and want to be able to display the amount of time the
employee held a rank before moving on to the next promotion. The Last
promotion to be calculated as (date() - LastPromo)

EXAMPLE:

RANK PromoDate TimeInGrade
FF 01/01/1990 365days
Lieut 01/01/1991 1460days
Capt 01/01/1995 4361days

How do I calc forward to the next field or iterate the filtered results
to get my solution?

Greg

Dec 11 '06 #1
3 1616
Create a query using your table.

Type an expression like this into a fresh column in the Field row:

NextPromoDate: (SELECT Min(PromoDate) AS MinOfPromoDate
FROM Table1 AS Dupe
WHERE (Dupe.EmpID = Table1.EmpID)
AND (Dupe.PromoDate Table1.PromoDat e))
Replace "Table1" with the name of your table.

Once you have that working, you can use Nz() to supply today's date if
there's no future promotion, and use DateDiff() to get the difference:

TimeInGrade: DateDiff(d", [PromoDate],
Nz((SELECT Min(PromoDate) AS MinOfPromoDate
FROM Table1 AS Dupe
WHERE (Dupe.EmpID = Table1.EmpID)
AND (Dupe.PromoDate Table1.PromoDat e)), Date()))

If subqueries are new, see:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail .comwrote in message
news:11******** **************@ f1g2000cwa.goog legroups.com...
Hello

My MainForm manages Employee records. I have created another form that
manages employee promotions. On the MainForm a button launches the
PromotionForm and lists the promotions for the employee shown on the
MainForm. The buttons clickevent looks like this: DoCmd.OpenForm
stDocName, , , "EMPID = " & Me.txtEMPID

The results are FILTERED. The Form is Continuous.
Fields are: (EmpID) (Rank) (PromoDate) and UnboundTxtBox:
(TimeInGrade)
I have placed a UnBound TextBox in the PromotionsForm called
(TimeInGrade) and want to be able to display the amount of time the
employee held a rank before moving on to the next promotion. The Last
promotion to be calculated as (date() - LastPromo)

EXAMPLE:

RANK PromoDate TimeInGrade
FF 01/01/1990 365days
Lieut 01/01/1991 1460days
Capt 01/01/1995 4361days

How do I calc forward to the next field or iterate the filtered results
to get my solution?

Greg

Dec 12 '06 #2
Thankyou Allen, that's a great idea and I will experiment with it.

Before your response, I have been pursuing the following:

RANK PromoDate TimeInGrade
FF 01/01/1990 365days
Lieut 01/01/1991 1460days
Capt 01/01/1995 4361days

How do I calc forward to the next field ???

In my subform I created a column called txtTimeInGrade and in the
ControlSource placed the function reference
=Days_DateDiff([PROMODATE],Date()) and it displays the result between
the promodate and todays date in the exact format I would like, however
the Date() parameter needs to be changed to a forward reference to the
next rows PromoDate to give me the difference between the promotion
dates. Something like:
=Days_DateDiff([PROMODATE],[PROMODATE].Row+1) but I am having
difficulty figuring out what the row reference syntax should be???
And then of course, if this works I will need to address the last
record issue attempting to forward reference a record that is not
there?

ThankYou
Greg

Dec 18 '06 #3
If you don't mind a read-only form (i.e. you don't need to edit the
records), you can use a subquery.

If you need it to be editable, you will need to use DLookup() in your form
instead. Unfortunately, DLookup() doesn't allow you to specify which record
you need to retrieve, so you will probbaly need to use this extended version
of the function called ELookup() instead:
http://allenbrowne.com/ser-42.html

More information about how to build queries to retrieve other values:
Getting a related field from a GroupBy (total) query
at:
http://www.mvps.org/access/queries/qry0020.htm
or:
Referring to a Field in the Previous Record or Next Record
at:
http://support.microsoft.com/kb/210504/en-us

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail .comwrote in message
news:11******** **************@ 48g2000cwx.goog legroups.com...
Thankyou Allen, that's a great idea and I will experiment with it.

Before your response, I have been pursuing the following:

RANK PromoDate TimeInGrade
FF 01/01/1990 365days
Lieut 01/01/1991 1460days
Capt 01/01/1995 4361days

How do I calc forward to the next field ???

In my subform I created a column called txtTimeInGrade and in the
ControlSource placed the function reference
=Days_DateDiff([PROMODATE],Date()) and it displays the result between
the promodate and todays date in the exact format I would like, however
the Date() parameter needs to be changed to a forward reference to the
next rows PromoDate to give me the difference between the promotion
dates. Something like:
=Days_DateDiff([PROMODATE],[PROMODATE].Row+1) but I am having
difficulty figuring out what the row reference syntax should be???
And then of course, if this works I will need to address the last
record issue attempting to forward reference a record that is not
there?

ThankYou
Greg

Dec 19 '06 #4

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

Similar topics

2
3007
by: Ryan Mitchley | last post by:
Hi all I have the functions friend CComplexMatrixTemp eye(const size_t nN); and friend CComplexMatrixTemp & chol(CComplexMatrixTemp &z); I would like create expressions of the form CComplexMatrixTemp x = chol(eye(6)), similar to MATLAB syntax.
5
1932
by: Thomas Matthews | last post by:
Hi, I have a Display class. I would like to write a function that takes a range of objects and displays them. The range would be specified by two forward iterators: start and end (one past start). I created a base class "References" to test this concept. I want the display function to process either a vector<References> or a list<References>. However, in my compiler (Borland C++ Builder), the std::list has a different iterator...
10
2234
by: Alan Lee | last post by:
Hi i am writing a small simulation for a bunch of atoms jumping around on a surface. I know i am a crappy programmer since i am not very familiar with object oriented languages. I am woindering if anyone can tell me why my forward class declarations not working. the member function findpaths can't seem to access the class Board when I try to pass it a board object by value. I put the Board class latrerbut also put in a forward...
11
2777
by: Randy Yates | last post by:
I'm having a problem with forward references. For example, class DATE; class MYCLASS; class MYCLASS { public:
6
2852
by: Markus Dehmann | last post by:
I have a circular dependency between two classes. The FAQ hint about a forward declaration does not help in my case ( How can I create two classes that both know about each other?) Error: "field `foo' has incomplete type" for the following code: #include <iostream> #include <vector>
4
3279
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the program is doing I show a window which contains a progress bar and a label. At some point during the execution the state of the calculation is changed, so I want to let the user know this. I have placed the creation of the form in a seperate thread...
7
15309
by: Michael B Allen | last post by:
I have a forward reference like: struct foo; int some_fn(struct foo *param); Because the parameter is a pointer the compiler is satisfied. But now I wan to change 'struct foo' to a typedef'd type like 'foo_t'. The following all fail to compile:
8
28470
by: Mohammad Omer Nasir | last post by:
Hi, i made a structure in header file "commonstructs.h" is: typedef struct A { int i; A( ) {
6
1372
by: barcaroller | last post by:
Why does the following code cause a compiler error? class A; // forward reference class B { foo() { a = new A;
0
9699
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
9562
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,...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7600
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
6840
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2968
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.