PC Review


Reply
Thread Tools Rate Thread

Function not recognized?

 
 
=?Utf-8?B?S291IFZhbmc=?=
Guest
Posts: n/a
 
      17th Mar 2006
I have inserted a function into one of my forms. When I just insert it into
a module by itself it works, but not in my form. It is from the compare 2
times in the Microsoft KB. Does this function need to be in it's own module
in order to work? When I try to call it in my form, it says it doesn't
recognize the sub or function. Thanks!

Option Explicit

Function ElapsedTTime(Interval)
Dim x
x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
Debug.Print x
x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
& " Minutes:Seconds"
Debug.Print x
x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
& " Hours:Minutes:Seconds"
Debug.Print x
x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
& " Hours " & Format(Interval, "nn") & " Minutes " & _
Format(Interval, "ss") & " Seconds"
Debug.Print x

End Function
 
Reply With Quote
 
 
 
 
Jörg
Guest
Posts: n/a
 
      17th Mar 2006
Hi,

i just created a simple form, only with one button called "Befehl0"

Then i put in the followin code:

---------------------------------------------------------------------
Option Compare Database
Option Explicit

Private Sub Befehl0_Click()
ElapsedTTime (2)
End Sub

Function ElapsedTTime(Interval)
Dim x
x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
MsgBox x
x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
& " Minutes:Seconds"
MsgBox x
x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
& " Hours:Minutes:Seconds"
MsgBox x
x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
& " Hours " & Format(Interval, "nn") & " Minutes " & _
Format(Interval, "ss") & " Seconds"
MsgBox x
End Function
---------------------------------------------------------------------

.... and it works without any problem...

Try it again

Best regards


"Kou Vang" <(E-Mail Removed)> schrieb im Newsbeitrag
news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> I have inserted a function into one of my forms. When I just insert it

into
> a module by itself it works, but not in my form. It is from the compare 2
> times in the Microsoft KB. Does this function need to be in it's own

module
> in order to work? When I try to call it in my form, it says it doesn't
> recognize the sub or function. Thanks!
>
> Option Explicit
>
> Function ElapsedTTime(Interval)
> Dim x
> x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> Debug.Print x
> x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> & " Minutes:Seconds"
> Debug.Print x
> x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> & " Hours:Minutes:Seconds"
> Debug.Print x
> x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> & " Hours " & Format(Interval, "nn") & " Minutes " & _
> Format(Interval, "ss") & " Seconds"
> Debug.Print x
>
> End Function



 
Reply With Quote
 
Roger Carlson
Guest
Posts: n/a
 
      17th Mar 2006
Not sure I understand, but if you create a function in the code behind a
form, it will only be available to THAT form. If you want the function to
be used globally, you have to put it in a Module.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L


"Kou Vang" <(E-Mail Removed)> wrote in message
news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> I have inserted a function into one of my forms. When I just insert it

into
> a module by itself it works, but not in my form. It is from the compare 2
> times in the Microsoft KB. Does this function need to be in it's own

module
> in order to work? When I try to call it in my form, it says it doesn't
> recognize the sub or function. Thanks!
>
> Option Explicit
>
> Function ElapsedTTime(Interval)
> Dim x
> x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> Debug.Print x
> x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> & " Minutes:Seconds"
> Debug.Print x
> x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> & " Hours:Minutes:Seconds"
> Debug.Print x
> x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> & " Hours " & Format(Interval, "nn") & " Minutes " & _
> Format(Interval, "ss") & " Seconds"
> Debug.Print x
>
> End Function



 
Reply With Quote
 
Jörg
Guest
Posts: n/a
 
      17th Mar 2006
Hi Roger,

that´s totally right,
but he/she wants to insert it into a form..
so he/she gets his/her answer how to user it in an form ;-)

best regards


"Roger Carlson" <NO-Roger.J.Carlson-(E-Mail Removed)> schrieb im Newsbeitrag
news:#(E-Mail Removed)...
> Not sure I understand, but if you create a function in the code behind a
> form, it will only be available to THAT form. If you want the function to
> be used globally, you have to put it in a Module.
>
> --
> --Roger Carlson
> MS Access MVP
> Access Database Samples: www.rogersaccesslibrary.com
> Want answers to your Access questions in your Email?
> Free subscription:
> http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L
>
>
> "Kou Vang" <(E-Mail Removed)> wrote in message
> news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> > I have inserted a function into one of my forms. When I just insert it

> into
> > a module by itself it works, but not in my form. It is from the compare

2
> > times in the Microsoft KB. Does this function need to be in it's own

> module
> > in order to work? When I try to call it in my form, it says it doesn't
> > recognize the sub or function. Thanks!
> >
> > Option Explicit
> >
> > Function ElapsedTTime(Interval)
> > Dim x
> > x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> > & " Minutes:Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> > & " Hours:Minutes:Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> > & " Hours " & Format(Interval, "nn") & " Minutes " & _
> > Format(Interval, "ss") & " Seconds"
> > Debug.Print x
> >
> > End Function

>
>



 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      17th Mar 2006
It has to be in the General section, after any declarations but before any
form object events.

"Jörg" wrote:

> Hi Roger,
>
> that´s totally right,
> but he/she wants to insert it into a form..
> so he/she gets his/her answer how to user it in an form ;-)
>
> best regards
>
>
> "Roger Carlson" <NO-Roger.J.Carlson-(E-Mail Removed)> schrieb im Newsbeitrag
> news:#(E-Mail Removed)...
> > Not sure I understand, but if you create a function in the code behind a
> > form, it will only be available to THAT form. If you want the function to
> > be used globally, you have to put it in a Module.
> >
> > --
> > --Roger Carlson
> > MS Access MVP
> > Access Database Samples: www.rogersaccesslibrary.com
> > Want answers to your Access questions in your Email?
> > Free subscription:
> > http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L
> >
> >
> > "Kou Vang" <(E-Mail Removed)> wrote in message
> > news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> > > I have inserted a function into one of my forms. When I just insert it

> > into
> > > a module by itself it works, but not in my form. It is from the compare

> 2
> > > times in the Microsoft KB. Does this function need to be in it's own

> > module
> > > in order to work? When I try to call it in my form, it says it doesn't
> > > recognize the sub or function. Thanks!
> > >
> > > Option Explicit
> > >
> > > Function ElapsedTTime(Interval)
> > > Dim x
> > > x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> > > & " Minutes:Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> > > & " Hours:Minutes:Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> > > & " Hours " & Format(Interval, "nn") & " Minutes " & _
> > > Format(Interval, "ss") & " Seconds"
> > > Debug.Print x
> > >
> > > End Function

> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?S291IFZhbmc=?=
Guest
Posts: n/a
 
      17th Mar 2006
The next step for me in order to use this, is to incorporate an interval from
fields off my form. So now I have:

TimeInterval = "#" & LstEndDate & " " & LstEndTime & _
"#-#" & LstBegDate & " " & LstBegTime & "#"

This is equivalent to: #11/3/2005 3:00:00 PM#-#11/1/2005 2:00:00 PM#

But now the function doesn't work? Is it because the interval is now a
string? Do I need to convert it before using the function
ElapsedTime(TimeInterval)? Any ideas?



"Jörg" wrote:

> Hi,
>
> i just created a simple form, only with one button called "Befehl0"
>
> Then i put in the followin code:
>
> ---------------------------------------------------------------------
> Option Compare Database
> Option Explicit
>
> Private Sub Befehl0_Click()
> ElapsedTTime (2)
> End Sub
>
> Function ElapsedTTime(Interval)
> Dim x
> x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> MsgBox x
> x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> & " Minutes:Seconds"
> MsgBox x
> x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> & " Hours:Minutes:Seconds"
> MsgBox x
> x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> & " Hours " & Format(Interval, "nn") & " Minutes " & _
> Format(Interval, "ss") & " Seconds"
> MsgBox x
> End Function
> ---------------------------------------------------------------------
>
> .... and it works without any problem...
>
> Try it again
>
> Best regards
>
>
> "Kou Vang" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> > I have inserted a function into one of my forms. When I just insert it

> into
> > a module by itself it works, but not in my form. It is from the compare 2
> > times in the Microsoft KB. Does this function need to be in it's own

> module
> > in order to work? When I try to call it in my form, it says it doesn't
> > recognize the sub or function. Thanks!
> >
> > Option Explicit
> >
> > Function ElapsedTTime(Interval)
> > Dim x
> > x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> > & " Minutes:Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> > & " Hours:Minutes:Seconds"
> > Debug.Print x
> > x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> > & " Hours " & Format(Interval, "nn") & " Minutes " & _
> > Format(Interval, "ss") & " Seconds"
> > Debug.Print x
> >
> > End Function

>
>
>

 
Reply With Quote
 
Jörg
Guest
Posts: n/a
 
      20th Mar 2006
Hi,

try this:

MsgBox DateDiff("h", #11/1/2005 2:00:00 PM#, #11/3/2005 3:00:00 PM#)

Best regards


"Kou Vang" <(E-Mail Removed)> schrieb im Newsbeitrag
news:BE60AEE0-8F8F-462C-97F0-(E-Mail Removed)...
> The next step for me in order to use this, is to incorporate an interval

from
> fields off my form. So now I have:
>
> TimeInterval = "#" & LstEndDate & " " & LstEndTime & _
> "#-#" & LstBegDate & " " & LstBegTime & "#"
>
> This is equivalent to: #11/3/2005 3:00:00 PM#-#11/1/2005 2:00:00 PM#
>
> But now the function doesn't work? Is it because the interval is now a
> string? Do I need to convert it before using the function
> ElapsedTime(TimeInterval)? Any ideas?
>
>
>
> "Jörg" wrote:
>
> > Hi,
> >
> > i just created a simple form, only with one button called "Befehl0"
> >
> > Then i put in the followin code:
> >
> > ---------------------------------------------------------------------
> > Option Compare Database
> > Option Explicit
> >
> > Private Sub Befehl0_Click()
> > ElapsedTTime (2)
> > End Sub
> >
> > Function ElapsedTTime(Interval)
> > Dim x
> > x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> > MsgBox x
> > x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> > & " Minutes:Seconds"
> > MsgBox x
> > x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> > & " Hours:Minutes:Seconds"
> > MsgBox x
> > x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> > & " Hours " & Format(Interval, "nn") & " Minutes " & _
> > Format(Interval, "ss") & " Seconds"
> > MsgBox x
> > End Function
> > ---------------------------------------------------------------------
> >
> > .... and it works without any problem...
> >
> > Try it again
> >
> > Best regards
> >
> >
> > "Kou Vang" <(E-Mail Removed)> schrieb im Newsbeitrag
> > news:453B5FEA-D01A-425A-BE72-(E-Mail Removed)...
> > > I have inserted a function into one of my forms. When I just insert

it
> > into
> > > a module by itself it works, but not in my form. It is from the

compare 2
> > > times in the Microsoft KB. Does this function need to be in it's own

> > module
> > > in order to work? When I try to call it in my form, it says it

doesn't
> > > recognize the sub or function. Thanks!
> > >
> > > Option Explicit
> > >
> > > Function ElapsedTTime(Interval)
> > > Dim x
> > > x = Int(CSng(Interval * 24 * 3600)) & " Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
> > > & " Minutes:Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
> > > & " Hours:Minutes:Seconds"
> > > Debug.Print x
> > > x = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
> > > & " Hours " & Format(Interval, "nn") & " Minutes " & _
> > > Format(Interval, "ss") & " Seconds"
> > > Debug.Print x
> > >
> > > End Function

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function not recognized mike Microsoft Access Form Coding 2 9th Oct 2008 09:56 PM
Function Not Being Recognized uma Microsoft Access 4 26th Jun 2006 07:30 PM
Function Not Being Recognized uma Microsoft Access 0 22nd Jun 2006 04:28 PM
MID Function not recognized =?Utf-8?B?TG9ycmFpbmU=?= Microsoft Access Queries 2 27th Dec 2005 06:39 PM
Function not Recognized Ken Microsoft Excel Worksheet Functions 2 29th Jun 2004 10:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 PM.