Help with Application.Run

Epic

Registered User.
Local time
Today, 15:14
Joined
Dec 23, 2004
Messages
58
I would like to lunch Procedures and Functions within VBA.

Looking in Help, Application.Run can do this but I can't make it work.

Can anybody post a piece of code which can run a Procedure from a stand alone module in the same database please?

Thanks.
 
What if you were to create a Macro that runs the code, then use the DoCmd.RunMacro?
 
Just make sure that the functions are public and you can use them the same as any other function

Public Function MyFunction(a, b)
MyFunction = a * b
End Function

c = MyFunction(10, 10)

HTH

Peter
 
Thanks guys!

What I want is to be able to execute different Functions and procedures from a form... I will create a module, send it to the users who will import in the DB then will use its Functions and Procedures by selecting them from a combo box.

RunCode from a macro runs only functions but not Procedures... this can be a solution for Functions but I do not know how to create a macro from vba.

Any comment/advise please?

Thanks.
 
If you can create a form, then make the module as you were, and include in the file you sent a form. The form has a combo box with all your function names in, a textbox for function results and a button. The button does a select statement on the value of the combo box, and runs the corresponding function/procedure(function results go into txtResult), i.e:

Select case combo
Case "Function 1"
txtResult = Function1
Case "Function 2"
txtResult = Function2
Case "Procedure 1"
Procedure1
etc
End Select

Hope this helps
 
Thanks workmad3

This is what I did... But I was tried to put together something like:

Combo values(cboObject): proTransferFtp; proDeleteSomething;funCountResults;frmList;qryAllData
Code:
Select case left(cboObject,3)
         case "pro", 'start Procedure
                Application.Run  cboObject
               'Based on help this should work but didn't. What is wrong?

         case "frm"
                docmd.OpenForm.... 'Others are OK

end select
 
You need to split your database. The front end [forms, queries, modules, reports, linked tables] would be all that you need to give to the users to update their application with your new and improved db. The back end would store all the data [shared] tables so the user will not loose any records when you publish and update.
 

Users who are viewing this thread

Back
Top Bottom