P
Phesunov
Is it possible to dynamically call a function based information provided in
a table field? That information being the name of the function.
I'm looking to consolidate 30 different functions to be triggered from a
form based on the user's input on what calculation process to use. I could
give each function a number reference in a table to call a hard coded
function name based on that reference number but I was looking for a way to
simplify it by incorporating the function name in the table itself.
Below is a sample procedure and one function. [Function Call] is a text
field in a form containing the name of the function (i.e. FDM_7_User(A, B, C)
). I'm trying to establish FCall as a variable to hold the name and to call
the function from. Any ideas would be helpful.
Thank you
========================
Private Sub BTN_Calculate_Click()
Dim A As Variant
Dim B As Variant
Dim C As Variant
Dim Answer As Variant
Dim FCall As Object
A = 5
B = "Tbl_Alpha"
C = True
'[Function Call]="FDM_7_User(A, B, C)"
Set FCall = [Function Call]
'This works
Answer = FDM_7_User(A, B, C)
'This doesn't
Answer = FCall
MsgBox (Answer)
End Sub
-----------------------------
Function FDM_7_User(A, B, C) As Variant
'A = Qty
'B = Source Table Name
'C = Local Functional need
MsgBox ("FDM7")
FDM_7_User = "Done"
End Function
a table field? That information being the name of the function.
I'm looking to consolidate 30 different functions to be triggered from a
form based on the user's input on what calculation process to use. I could
give each function a number reference in a table to call a hard coded
function name based on that reference number but I was looking for a way to
simplify it by incorporating the function name in the table itself.
Below is a sample procedure and one function. [Function Call] is a text
field in a form containing the name of the function (i.e. FDM_7_User(A, B, C)
). I'm trying to establish FCall as a variable to hold the name and to call
the function from. Any ideas would be helpful.
Thank you
========================
Private Sub BTN_Calculate_Click()
Dim A As Variant
Dim B As Variant
Dim C As Variant
Dim Answer As Variant
Dim FCall As Object
A = 5
B = "Tbl_Alpha"
C = True
'[Function Call]="FDM_7_User(A, B, C)"
Set FCall = [Function Call]
'This works
Answer = FDM_7_User(A, B, C)
'This doesn't
Answer = FCall
MsgBox (Answer)
End Sub
-----------------------------
Function FDM_7_User(A, B, C) As Variant
'A = Qty
'B = Source Table Name
'C = Local Functional need
MsgBox ("FDM7")
FDM_7_User = "Done"
End Function