How To Call A Function From A Variable?

JGravesNBS
NewLounger
Posts: 4
Joined: 05 Apr 2014, 16:40

How To Call A Function From A Variable?

Post by JGravesNBS »

I have the following in Form and it works OK

Call RunForm("frmProviderLookup", "", "Edit", "", "", "Normal", "Normal")

I want to build a combo box with several different RunForm variations as follows:

RunForm("frmProviderLookup", "", "Edit", "", "", "Normal", "Normal")
RunForm("frmCustomerLookup", "", "Edit", "", "", "Normal", "Normal")
RunForm("frmVendorLookup", "", "Edit", "", "", "Normal", "Normal")
etc, there are many of these

When I select one the variations from the combo box the RunForm statement is stored in strAction varaible

How do I code the Call strAction line? (I want only one call statement)

In other words how to call a Function from a variable

The start of my module Function works OK and looks like this:

Public Function RunForm(FormName As String, _
Optional WhereCondition As String = "", _
Optional xMode As String = "", _
Optional filterName As String = "", _
Optional Args As String = "", _
Optional WindowMode As String = "", _
Optional View As String = "")

' Parameters (all optional except parameter 1)
' 1 - Form Name
' 2 - Where condition
' 3 - Mode [Add, Edit, View(Read Only), ""(PropertySettings), DS(Datasheet Edit)]
' 4 - Filter Name
' 5 - Opening Arguments
' 6 - Window Mode
' 7 - Form View

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: How To Call A Function From A Variable?

Post by HansV »

Welcome to Eileen's Lounge!

You can use the Eval function for this purpose:

Call Eval(strAction)
Best wishes,
Hans

JGravesNBS
NewLounger
Posts: 4
Joined: 05 Apr 2014, 16:40

Re: How To Call A Function From A Variable?

Post by JGravesNBS »

Thanks Hans, works great!