Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Run Procedure

Status
Not open for further replies.

123FakeSt

IS-IT--Management
Aug 4, 2003
182
I want to store all of my actions for my command buttons in a table, so when a form is loaded, the actions are loaded from the table.

The buttons that open new forms (form navigation) was easily accomplished with this code (where menAction value of 1 is open form and 2 is run code):

Code:
Dim strSQL As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

strSQL = "SELECT * FROM utbMenu WHERE menOrder = " &  intOption & " AND menSource = '" & Me.Name & "'"
rst.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rst.EOF Then
    rst.MoveFirst
    Select Case rst!menAction
        Case 1
            DoCmd.OpenForm rst!menForm, acNormal, , , , acWindowNormal
        Case 2
             'execute the procedure rst!menCode
    End Select
End If

Any hints? I hope I don't have to write to a module and assign it to the buttons to do this...

The early bird gets the worm, but the second mouse gets the cheese.
 
Case 2
Eval rst!menCode & "()" 'execute the [!]function[/!] rst!menCode

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks ... I can't believe I've never discovered the
Code:
Eval
command before. It can do a lot.

The early bird gets the worm, but the second mouse gets the cheese.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top