Is it possible to use a variable name to call a function- In the following example, I am trying to use the strSACName variable to call a function - The function that will be called will depend on the username... since each user has different assignments I am tailoring each function to the user.
The function will set the query criteria for me depending on who the user is.
Please be kind if I am way off base here.
When I use the following and use the specific function name I am ok - However, when I replace the function name with the variable "strSACName" I get a compile error saying "expected array"
Sorry if this looks sloppy but I am learning the vba side.
Private Sub cmdRunRpt_Click()
Dim strSACName As String
Dim strUser As String
Dim lngOptionValue As Long
Dim lngX As Long
Dim strRestrict As String
strUser = GetUserName
strSACName = strUser & "Brokers"
'assign the value of the option group to lngX
lngX = Forms!SACSpecific!SACBrokerRun.Value
'use getusername function to get windows user name
strRestrict = strSACName(lngX)
End Sub
Thank you very much!!!!
The function will set the query criteria for me depending on who the user is.
Please be kind if I am way off base here.
When I use the following and use the specific function name I am ok - However, when I replace the function name with the variable "strSACName" I get a compile error saying "expected array"
Sorry if this looks sloppy but I am learning the vba side.
Private Sub cmdRunRpt_Click()
Dim strSACName As String
Dim strUser As String
Dim lngOptionValue As Long
Dim lngX As Long
Dim strRestrict As String
strUser = GetUserName
strSACName = strUser & "Brokers"
'assign the value of the option group to lngX
lngX = Forms!SACSpecific!SACBrokerRun.Value
'use getusername function to get windows user name
strRestrict = strSACName(lngX)
End Sub
Thank you very much!!!!