[Access 2000] automated Updaing Modules,Form Classes
Hi,
I have built an app and wish to add simple Erorr handling.
My basic error handling will be
VB Code:
On Error GoTo ErrorHandler
iniclsUser
CreateSiteEvent "test", "TESTING", 1
CreateJobEvent "test", "TESTING", 1
ErrorHandler:
LogError err.Number,"mdlGlobal","testSiteCreation",err.Description
is there a way to open each module and add these lines Capturing the Module name that i am in and the sub/function name using code ?
thansk
David
Re: [Access 2000] automated Updaing Modules,Form Classes
Not sure if there is something in the err class (type err. into the debug window and see.
Otherwise, create a global (public) variable, set it when entering a sub/function so if it errors you know where.
Re: [Access 2000] automated Updaing Modules,Form Classes
hi,
Sorry i think i did not explain well enough.
I want to write a module that will actualy open the modules and form classes then at the top after the var declaration it will put in the code to declare the error handler and then add the actual Error handling at the botom (inclsive of exit sub at the botom where the code as temrminated)
thanks
David
Re: [Access 2000] automated Updaing Modules,Form Classes
It is possible to do, but
It will require some advanced coding :)
also you'd need to add the error handling to all subs/functions not just hte module.
I think you can find it in DAO fairly easy, as DAO is access based it should allow you to open and view code. Not sure about the actual editting and saving tho.
Perhaps search msdn as they usually have something on it. Or google search.
if you can find stuff using the intellisense at least you can search for help on it directly
good luck
Re: [Access 2000] automated Updaing Modules,Form Classes
Hey, Davadvice. First I would like to introduce you to MZ-Tools. It's free for office VBA and has lots of nice tools that you don't know you can't live without. One of them will add error handling to a sub with the click of a toolbar button. You can customize how it handles this.
http://www.mztools.com/index.aspx
Now to directly answer your question, you will be dealing with the VBIDE object. This method of modifying code is exactly the same for all VBA applications. You will find tutorial and example code here.
http://www.cpearson.com/excel/vbe.aspx