Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value conversion

Status
Not open for further replies.

Tronsliver

Technical User
Sep 19, 2000
120
US
I'm looking for the ability to strip the decmial off a number after a division operation. Also I want to convert a value into a String. Here is the code. The "Left" function and the "Str" funtion isn't reconized. Can someone give me a comparible solution?

Public Function Caldates(EffectiveDate)
Dim TheDate As Variant

TheDate = DateDiff("m", EffectiveDate, Now)

If TheDate >= 12 Then
TheDate = Left(Str(TheDate / 12), 4)
Caldates = TheDate + " Yr"
Else
If TheDate < 12 Then
TheDate = TheDate
CalDate = TheDate + &quot; Months&quot;
End If
End If

End Function
 
Hi!

Try using TheDate = Int(TheDate/12).

hth
Jeff Bridgham
 
Actually, the &quot;problem&quot; lies elsewhere. IF the issue is 'recognizing' the Left & Str functions, yoiu must have a reference(s) ieeus to deal with. Otherwise, you have an Un-Necessary IF/End If in the else section and have &quot;Miss-spelled&quot; the function name in that same area. See the revised code below.

Code:
Public Function Caldates(EffectiveDate)
    Dim TheDate As Variant

    TheDate = DateDiff(&quot;m&quot;, EffectiveDate, Now)

    If (TheDate >= 12) Then
        TheDate = Left(str(TheDate / 12), 4)
        Caldates = TheDate + &quot; Yr&quot;
     Else
'        If (TheDate < 12) Then
            TheDate = TheDate
            Caldates = str(TheDate) + &quot; Months&quot;
'        End If
    End If

End Function
MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
When I run the code I get &quot;can't find library or project&quot; error message? Any ideas?
 
Ah, Hmmmmmmmmmmm, So,

It is the references thinnggggyyyyyy. I am not really familiar with which ones you need to be in what order. But some where you have gotten the installation corrupted and hte ref to the intrinsic fumctions is gone astray.

A way to fix it could be to just re-install the Ms. Access version. If it happens to be Ms. Access '95 (really retro stuffffff!) the default installation does not include the 'library' for VBA functions, and you will need to do a custom installation. Otherwise, I'm not sure where what is supposed to be.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top