B
Bob
Hi,
Apologies for posting this in 2 groups as not sure where it fits -
coding or macros.
I'm trying to open one of several Excel spreadsheets from a command
button on a form.
What I have at the moment is a macro with RunCode as its Action
The macro runs the function with the value of a text box on a form as
the variable value
=OpenKPI([Forms]![frmChooseAdviser]![Adviser])
The function is as follows
Public Function OpenKPI(Adviser As String)
Select Case Adviser
Case "Zach McArthur"
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Zach Data
Capture.xls"
Case "Stuart McCarron"
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Stuart Data
Capture.xls"
Case Else
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Data Capture.xls"
End Select
End Function
When I run the macro I get an error stating "The expression you
entered contains invalid syntax" and "You may have entered a comma
without a preceding value or identifier" which doesnt make any sense
to me.
When I click OK to that, the Action Failed box pops up where it lists
the Argument as
\\s-coyote\ifpstaff\Advisers_WIP\Stuart Data Capture.xls
which is correct.
So, it identifies the correct file path based on the Select Case in
the function but it fails to open the file.
Any ideas what I'm doing wrong.
Thanks
Bob
Apologies for posting this in 2 groups as not sure where it fits -
coding or macros.
I'm trying to open one of several Excel spreadsheets from a command
button on a form.
What I have at the moment is a macro with RunCode as its Action
The macro runs the function with the value of a text box on a form as
the variable value
=OpenKPI([Forms]![frmChooseAdviser]![Adviser])
The function is as follows
Public Function OpenKPI(Adviser As String)
Select Case Adviser
Case "Zach McArthur"
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Zach Data
Capture.xls"
Case "Stuart McCarron"
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Stuart Data
Capture.xls"
Case Else
OpenKPI = "\\s-coyote\ifpstaff\Advisers_WIP\Data Capture.xls"
End Select
End Function
When I run the macro I get an error stating "The expression you
entered contains invalid syntax" and "You may have entered a comma
without a preceding value or identifier" which doesnt make any sense
to me.
When I click OK to that, the Action Failed box pops up where it lists
the Argument as
\\s-coyote\ifpstaff\Advisers_WIP\Stuart Data Capture.xls
which is correct.
So, it identifies the correct file path based on the Select Case in
the function but it fails to open the file.
Any ideas what I'm doing wrong.
Thanks
Bob