Module results in a label

Anonymous_354

Duct tape lovers UNITE!
Local time
Today, 12:26
Joined
Jun 6, 2007
Messages
74
I'm wondering how to set Label139 to display the results from a module. The module displays the date and time a file was modified. I'm sure it's a simple fix, I'm just not sure how to do it. Any thoughts?
 
Me.Label139.Caption = YourFunctionNameHere

That is, if your function is correctly configured to return a value.
 
Is there a special way to make them "compatible" with each other?
 
Meaning, is there anything special that I have to do in my module to make it display it's contents wherever I so decide to insert them?
 
Not really, you just have to figure out what event to put it on to assign the value.
 
I simply put it under the OnTimer event that triggers every 100 miliseconds. It's also running a clock. Should all that worK?
 
How come this doesn't work?
Code:
    Me.Label139.Caption = getFileDateTime.getLastModified
It claims it expected a function or variable.

My module looks like this.
Code:
Public Sub getLastModified()
    ' Initialize variables
    Dim lastModifiedDateTime As Date
    
    ' Run code
    lastModifiedDateTime = FileDateTime(Environ("USERPROFILE") & "\My Documents\Experiment.mdb")
End Sub
 
Me.Label139.Caption = getFileDateTime.getLastModified

Should be:

Me.Label139.Caption = getLastModified

or, if the other part is another function then

Me.Label139.Caption = getFileDateTime & " " & getLastModified
 
Still doesn't work... Same error "Compile error: Expected function or variable"
 
Did you put this:

Code:
Public Sub getLastModified()
    ' Initialize variables
    Dim lastModifiedDateTime As Date
    
    ' Run code
    lastModifiedDateTime = FileDateTime(Environ("USERPROFILE") & "\My Documents\Experiment.mdb")
End Sub
in a STANDARD module (not a form module) and also, you need to return the value for the function, so it would be:

Code:
Public Function getLastModified() As Date
' Initialize variables
    Dim strFile As String

    strFile = Environ("USERPROFILE")
    strFile = strFile & "\My Documents\db3.mdb"

    ' return results
    getLastModified = FileDateTime(strFile)
End Function
 

Users who are viewing this thread

Back
Top Bottom