I'm sure this is insanely obvious... but i can't figure it out.
I have a db that organises applications for an event. Included in the
applicant information is their date of birth. On a form or report i can
calculate and display their current age (=(DateDiff("d",[DOB],Date()))/365)
and also their age at the time (=(DateDiff("d",[DOB],"28/07/07"))/365) of
the event.
As you can see i'm using a hardcoded date for the event date so i have to
change the expression all over the place. How can i set this date in one
location and reference it throughout the application?
cheers,
/mark 6 1464
Mark,
You could calculate theese ages in a query and use it as a source for forms
and/or reports.
"Mark Weedon" <ma**@markweedon.co.uka écrit dans le message de news: hO********************@pipex.net...
I'm sure this is insanely obvious... but i can't figure it out.
I have a db that organises applications for an event. Included in the
applicant information is their date of birth. On a form or report i can
calculate and display their current age
(=(DateDiff("d",[DOB],Date()))/365)
and also their age at the time (=(DateDiff("d",[DOB],"28/07/07"))/365) of
the event.
As you can see i'm using a hardcoded date for the event date so i have to
change the expression all over the place. How can i set this date in one
location and reference it throughout the application?
cheers,
/mark
Hello Mark,
I tried following :
a) create a module where I create following constant :
Public Const cEventDate As Date = "28/07/07"
b) create a testform with following code in its on-open event :
Private Sub Form_Open(Cancel As Integer)
MsgBox (DateDiff("d", "28/09/06", cEventDate))
End Sub
Conclusion : result was correct and I only need to change the value of
the constant
whenever there's a new event date.
Hope this works for you...
Regards,
Rudi.
Rudi,
Right, but in order to use that constant in reports, you'd have to have
a public function:
Public Function fEventDate() as Date
fEventDate = cEventDate
End Function
Then, you could use
=(DateDiff("d",[DOB],fEventDate()/365)
Chris Nebinger
Rudi wrote:
Hello Mark,
I tried following :
a) create a module where I create following constant :
Public Const cEventDate As Date = "28/07/07"
b) create a testform with following code in its on-open event :
Private Sub Form_Open(Cancel As Integer)
MsgBox (DateDiff("d", "28/09/06", cEventDate))
End Sub
Conclusion : result was correct and I only need to change the value of
the constant
whenever there's a new event date.
Hope this works for you...
Regards,
Rudi.
"Mark Weedon" <ma**@markweedon.co.ukwrote in
news:hO********************@pipex.net:
I have a db that organises applications for an event. Included in the
applicant information is their date of birth. On a form or report i
can calculate and display their current age
(=(DateDiff("d",[DOB],Date()))/365) and also their age at the time
(=(DateDiff("d",[DOB],"28/07/07"))/365) of the event.
If it's important that the age be accurate to the day then I'd suggest
Googling this group for an accurate Age function. It's surprising how much
ill will can be generated by being a day or two out.
If on 28/Jul/07 you use your function to tell a woman born on 30/Jul/1977
that she's over thirty, then you may need to take steps to avoid a problem.
Big, fast steps.
Cheers,
Alan Carpenter
Chris,
thanks for pointing that out. I was too hasty, but then again,
according to Alan's justified remark I might have reason enough to! :-)
Thanks guys.
Rudi.
So... why when i create a form... have a text box can't i set the value of
that text box...
where do i put the expression =(DateDiff("d",[DOB],cEventDate()/365))?
Control Source??
Cheers,
/mark
<ch************@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Rudi,
Right, but in order to use that constant in reports, you'd have to have
a public function:
Public Function fEventDate() as Date
fEventDate = cEventDate
End Function
Then, you could use
=(DateDiff("d",[DOB],fEventDate()/365)
Chris Nebinger
Rudi wrote:
>Hello Mark,
I tried following :
a) create a module where I create following constant :
Public Const cEventDate As Date = "28/07/07"
b) create a testform with following code in its on-open event :
Private Sub Form_Open(Cancel As Integer) MsgBox (DateDiff("d", "28/09/06", cEventDate)) End Sub
Conclusion : result was correct and I only need to change the value of the constant whenever there's a new event date.
Hope this works for you...
Regards, Rudi.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rafe Culpin |
last post by:
Does anyone please know of a way to access static methods of a class, when
the name of that class is held in a variable?
I have several classes (PHP5) which all have identically named methods and...
|
by: rain_c1 |
last post by:
hi!
is there a way to access a static member of a class, if the classname
is a variable?
this does not work:
$classname::$member
for methods there is a solution:...
|
by: iamahulk |
last post by:
Why do I get a warning:
Access of shared member, constant member, enum member or nested type through
an instance; qualifying expression will not be evaluated
When accessing a shared method in...
|
by: djhulme |
last post by:
Hi,
I'm using GCC. Please could you tell me, what is the maximum number of
array elements that I can create in C, i.e.
char* anArray = (char*) calloc( ??MAX?? , sizeof(char) ) ;
I've...
|
by: Martin Pöpping |
last post by:
Hello,
I´ve implemented a Hashtable with Int-Keys and Double Values.
Now I want to get the i-th Int-Key of my hashtable.
How do I do that?
I tried it like that:
ICollection intKeys =...
|
by: tim85 |
last post by:
Hello,
Can anyone please advise me how to retrieve the value of a constant at runtime, given only its name (in a String).
I have experimented with the...
|
by: DanThMan |
last post by:
This seems like it should be so simple, but I'm just not having much
luck with this. I have an constant in my App.xaml.cs file (i.e., code-
behind) called Name.
public const string Name = "Dan";...
|
by: bernd |
last post by:
Hi folks,
a simple question for the experts, I guess.
Obviously I am doing something wrong when trying to access an element
of an array declared within a structure:
#include <stdio.h>...
|
by: s0suk3 |
last post by:
This code
#include <stdio.h>
int main(void)
{
int hello = {'h', 'e', 'l', 'l', 'o'};
char *p = (void *) hello;
for (size_t i = 0; i < sizeof(hello); ++i) {
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |