Darren DICK
darrend at nimble.com.au
Mon Jan 30 20:45:38 CST 2006
Hello all
I have a nice function that finds the file name from a given path
Function is called f_GetPath - Picked it up from the AccessD Archives - See foot
of this email
To call it in access I would do something like...
Private Sub txtSomeTextField_AfterUpdate()
debug.print f_GetPath(me.txtSomeTextField)
End Sub
So if the original value passed was C:\Program Files\Some Folder\coolfile.txt
the result in the debug window would be coolfile.txt
In Reporting Services I have a text Box
With a value of Fields!FileName.Value
It shows values similar to w:\Operations\Data Files\ImportedData\WW23879.A23
All I want to show is the actual file name bit not the full path - EG
WW23879.A23
SO I set the value of the text box to f_GetPath(Fields!Filename.Value)
And placed the f_GetPath function inside the MacroExplorer Under MyMacros
But now when I preview the report I get...
The value expression for the textbox 'txtFileName' contains an error: [BC30451]
Name 'f_GetPath' is not declared.
So...How do I declare f_GetPath
Many thanks in advance
Darren
-----------------------------
Function f_GetPath(ByVal aPath) As String
' Strips the path name from the supplied file and path name
' leaves the trailing slash on there
Dim foo As Integer, aSlash As Integer
aSlash = 0
foo = InStr(aPath, "\")
While (foo > 0)
aSlash = foo
foo = InStr(aSlash + 1, aPath, "\")
End While
If aSlash > 0 Then
f_GetPath = Left$(aPath, aSlash)
Else
f_GetPath = aPath
End If
End Function