May 4 2012, 03:15 AM
I have a problem using a button on a report opening an excel file.
When hardcoding the hyperlink the required document opens but when reading the path & filename from a table storing all paths and filenames it doesn't open the file.
(Path and filename are on the report in
Me.button.HyperlinkAddress = "C:\Local files\filename.xls"
the excel file filename.xls opens
dim strlink as string
strLink = Chr$(34) & Me.path.Value & Me.DocName.Value & Chr$(34)
Me.button.HyperlinkAddress = strLink
strLink holds the same refference "C:\Local files\filename.xls" as when using the address hardcoded...
I get the message that the file cannot be opened???
What am I doing wrong???
You do not need to enclose Me.path.Value & Me.DocName.Value in quotes. You are not building
an SQL statement.
Drop the Chr$(34) assignments.
With Me.button.HyperlinkAddress = "C:\Local files\filename.xls" quotes are needed because you are assigning
a literal string to a variable.
With strLink = Me.path.Value & Me.DocName.Value you assigning the combination of two variables to a third
variable and then to the property of a class.
May 4 2012, 06:51 AM
So simple but so hard to spot the error.
Thanks a lot, I just didn't "see" my obvious mistake...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here