473,503 Members | 939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modifying Age Function

I have the following function.

Function Age(varBirthdate As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirthdate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthdate, Now)
If Date < DateSerial(Year(Now), Month(varBirthdate),
Day(varBirthdate)) Then
varAge = varAge - 1
End If

Age = CInt(varAge)

End Function

I would like to modify it to calculate the Age of a person from the date
he entered the program so I rewrote one of the lines to this

varAge = DateDiff("yyyy", varBirthdate, tblClients.IntakeDate)

I receive a Compile Error: Fucntion call on left-hand side of assignment
must return Variant or Object.

I would like to know what I am doing wrong and how to correct it.

Thank you,
Deborah

Nov 12 '05 #1
2 4919
> Function Age(varBirthdate As Variant, MyDate as Date) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirthdate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthdate, MyDate)
If Date < DateSerial(Year(Now), Month(varBirthdate),
Day(varBirthdate)) Then
varAge = varAge - 1
End If

Age = CInt(varAge)

End Function

Then you have to pass the value to the function, in the Design Grid:

QueryField: Age([BirthDate], [MyDate])

P

"Deborah V. Gardner" <dg******@twcny.rr.com> wrote in message
news:3F***************@twcny.rr.com... I have the following function.

Function Age(varBirthdate As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirthdate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthdate, Now)
If Date < DateSerial(Year(Now), Month(varBirthdate),
Day(varBirthdate)) Then
varAge = varAge - 1
End If

Age = CInt(varAge)

End Function

I would like to modify it to calculate the Age of a person from the date
he entered the program so I rewrote one of the lines to this

varAge = DateDiff("yyyy", varBirthdate, tblClients.IntakeDate)

I receive a Compile Error: Fucntion call on left-hand side of assignment
must return Variant or Object.

I would like to know what I am doing wrong and how to correct it.

Thank you,
Deborah

Nov 12 '05 #2
Phobos

Thank you. It worked!

Deborah

Phobos wrote:
Function Age(varBirthdate As Variant, MyDate as Date) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirthdate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthdate, MyDate)
If Date < DateSerial(Year(Now), Month(varBirthdate),
Day(varBirthdate)) Then
varAge = varAge - 1
End If

Age = CInt(varAge)

End Function


Then you have to pass the value to the function, in the Design Grid:

QueryField: Age([BirthDate], [MyDate])

P

"Deborah V. Gardner" <dg******@twcny.rr.com> wrote in message
news:3F***************@twcny.rr.com...
I have the following function.

Function Age(varBirthdate As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirthdate) Then Age = 0: Exit Function

varAge = DateDiff("yyyy", varBirthdate, Now)
If Date < DateSerial(Year(Now), Month(varBirthdate),
Day(varBirthdate)) Then
varAge = varAge - 1
End If

Age = CInt(varAge)

End Function

I would like to modify it to calculate the Age of a person from the date
he entered the program so I rewrote one of the lines to this

varAge = DateDiff("yyyy", varBirthdate, tblClients.IntakeDate)

I receive a Compile Error: Fucntion call on left-hand side of assignment
must return Variant or Object.

I would like to know what I am doing wrong and how to correct it.

Thank you,
Deborah


Nov 12 '05 #3

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

Similar topics

15
2456
by: Paul Paterson | last post by:
I am trying to find a way to mimic by-reference argument passing for immutables in Python. I need to do this because I am writing an automated VB to Python converter. Here's an example of the VB...
6
8299
by: qwweeeit | last post by:
Hi all, when I was young I programmed in an interpreted language that allowed to modify itself. Also Python can (writing and running a module, in-line): fNew =open("newModule.py",'w') lNew=...
11
3902
by: Jason Heyes | last post by:
Look at my code: void modify_element(BigType &x) { /* not shown */ } BigType modify_element_copy(BigType x) { modify_element(x);
4
2179
by: VA | last post by:
I am using a JS library of functions that I include in my web page using the usual <script type="text/javascript" src=...> method Is there a way to automatically call one of my own functions...
9
1838
by: Stefan Mueller | last post by:
I'd like to set a variable called 'FocusIsOn' if a button got the focus. Because my button is dynamically created I do it like xelement = document.createElement("input") xelement.type = "button"...
7
3502
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the...
2
2552
by: chuck | last post by:
Hi, I am modifying some code from here http://www.quirksmode.org/dom/domform.html I have a div 'readroot' that I clone. I change the change the id and name of the childnodes of 'readroot' to...
13
2105
by: Robin Becker | last post by:
When young I was warned repeatedly by more knowledgeable folk that self modifying code was dangerous. Is the following idiom dangerous or unpythonic? def func(a): global func, data data =...
11
2974
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
0
7282
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
7339
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
7463
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...
1
5017
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...
0
4678
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...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
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 ...
0
389
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...

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.