[AccessD] [SPAM SUSPECT] Help with Syntax error

Bobby Heid bheid at appdevgrp.com
Thu Feb 9 06:19:31 CST 2006


Joe,

Also, you do know that you can get the difference in years with datediff,
don't you?

ldiff = Datediff("y", date1,date2)

Bobby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Wednesday, February 08, 2006 3:33 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] [SPAM SUSPECT] Help with Syntax error


Joe,

Firstly, yearcalc needs to be a function that returns a long (I assume that
is what you would want).

Public Function yearcalc(date1 As Date, date2 As Date) as long
dim lDiff as long

   ldiff = clng((Datediff("m", date1,date2)/12))

   yearcalc=ldiff

 End Sub


The calling code would need to be something like:

dim lRet as long

   lRet=yearcalc(date1,date2)


Bobby


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Joe Hecht
Sent: Wednesday, February 08, 2006 3:15 PM
To: 'Access Developers discussion and problem solving'
Subject: [SPAM SUSPECT] [AccessD] Help with Syntax error
Importance: Low


The idea here is get the difference in years between 2
dates.

 

This is a global module.

 

Public Sub yearcalc(date1 As Date, date2 As Date)

   = int(Datediff("m", date1,date2)/12)

 End Sub

 

 

=int line returns syntax error

 

 

This is the code I want to call the above

 

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim DOB As Date

Dim txtIDATE As Date

 Set DOB = date1

 Set txtIDATE = date2

 Call yearcalc

 

Thanks

 

Joe Hecht

jmhecht at earthlink.net




More information about the AccessD mailing list