473,657 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modifying Age Function

I have the following function.

Function Age(varBirthdat e As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirth date) Then Age = 0: Exit Function

varAge = DateDiff("yyyy" , varBirthdate, Now)
If Date < DateSerial(Year (Now), Month(varBirthd ate),
Day(varBirthdat e)) 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.Inta keDate)

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 4927
> Function Age(varBirthdat e As Variant, MyDate as Date) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirth date) Then Age = 0: Exit Function

varAge = DateDiff("yyyy" , varBirthdate, MyDate)
If Date < DateSerial(Year (Now), Month(varBirthd ate),
Day(varBirthdat e)) 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.r r.com... I have the following function.

Function Age(varBirthdat e As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirth date) Then Age = 0: Exit Function

varAge = DateDiff("yyyy" , varBirthdate, Now)
If Date < DateSerial(Year (Now), Month(varBirthd ate),
Day(varBirthdat e)) 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.Inta keDate)

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(varBirthdat e As Variant, MyDate as Date) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirth date) Then Age = 0: Exit Function

varAge = DateDiff("yyyy" , varBirthdate, MyDate)
If Date < DateSerial(Year (Now), Month(varBirthd ate),
Day(varBirthdat e)) 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.r r.com...
I have the following function.

Function Age(varBirthdat e As Variant) As Integer

'Function from Microsoft Article Q210522

Dim varAge As Variant

If IsNull(varBirth date) Then Age = 0: Exit Function

varAge = DateDiff("yyyy" , varBirthdate, Now)
If Date < DateSerial(Year (Now), Month(varBirthd ate),
Day(varBirthdat e)) 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.Inta keDate)

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
2487
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 code: Sub Change(ByVal x, ByRef y) x = x+1 y = y+1 End Sub
6
8310
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= fNew.writelines(lNew) fNew.close()
11
3920
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
2204
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 when function foo(...) (from the library) is called? In other words, when foo() is executed, check to see if there is an "execute me also" type of function (associated with foo) defined and if
9
1861
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" element.onfocus = function() {FocusIsOn = "Button_1"; alert(FocusIsOn)} That works great. If the button gets the focus, I got a message box saying 'Button_1'. However, if I set the variable 'FocusIsOn' dynamically (using a variable
7
3522
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 necessary changes on the functions and recreated all my types and functions. It seemd to be all right, but the newly created functions won't work anymore.
2
2563
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 the original name plus a number(counter). The problem is I have i have a div 'serials' inside 'readroot' and the childnodes of
13
2117
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 = somethingcomplexandcostly() def func(a): return simple(data,a)
11
3005
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. It works perfectly (assigning the correct images and the correct onclick events to the correct <atags):
0
8411
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
8838
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
8513
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
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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
5638
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
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.