473,756 Members | 4,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a constant

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

Oct 30 '06 #1
6 1475
Mark,
You could calculate theese ages in a query and use it as a source for forms
and/or reports.

"Mark Weedon" <ma**@markweedo n.co.uka écrit dans le message de news:
hO************* *******@pipex.n et...
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



Oct 30 '06 #2

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(Cance l 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.

Oct 30 '06 #3
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(Cance l 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.
Oct 30 '06 #4
"Mark Weedon" <ma**@markweedo n.co.ukwrote in
news:hO******** ************@pi pex.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
Oct 31 '06 #5
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.

Oct 31 '06 #6
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.goo glegroups.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(Cance l 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.

Nov 1 '06 #7

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

Similar topics

2
2649
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 members. I want to pass the name of one of the classes to an included file which does some standard operations using those methods and members. (So several different programs can include that file, each passing a different class name.)
0
1297
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: call_user_func(array($classname, 'method'));
1
1310
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 the framework. (for example) If Control.MouseButtons = MouseButtons.None Then.... What is the point of includes if they don't prevent this type of warning? Will I always need to explicitly specify the name space? If Control.MouseButtons =...
38
3005
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 managed to create arrays using DOUBLE data types, but when I try to access the array, the compiler complains that the number is not an INT, i.e.
8
2079
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 = myHashtable.Keys;
0
1042
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 Microsoft.VisualBasic.Interaction.CallByName() method, but without success. Alternatively, can you suggest how to import string constants for use as control property values; something along the followng lines ... <asp:label text="<%= myConstant %>" />
2
9863
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"; And now, I want a Label on my Window1.xaml page that shows the Name. I will eventually want to show the same Name on other pages. So, I want to be able to access (bind to?) this global constant from anywhere in the project.
15
3771
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> #include <stddef.h>
16
6796
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) {
0
9325
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
9930
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...
0
9716
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9716
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
9571
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
7116
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
6410
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();...
1
3676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.