Link to home
Start Free TrialLog in
Avatar of trbaze
trbaze

asked on

Recording Degugging Information

I have a function that records the errors in the program to a table.  Is there any way of finding either the line number or line of code that won't execute so I can record that as well?  
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Provided you have applied line numbers then ERL will give you the error line number.
Avatar of trbaze
trbaze

ASKER

How about just the line of code then, like docmd.Openform?
Among the many other things the free cool app does, it will add line numbers.  I use it daily.

http://www.mztools.com/v3/mztools3.aspx

mx
Avatar of trbaze

ASKER

How do you reference the line number?
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trbaze

ASKER

That works perfect!  Thank you very much!
Avatar of trbaze

ASKER

This just corrupted my DB.  The errors I get are that the expression entered does not match the procedure name.  Includes everything like OnLoad, OnCurrent, OnCllick.
Avatar of trbaze

ASKER

The code  and line numbers added by the toolbar.
I've been using MZTools for years and have never seen an instance of failure, especially adding Line Numbers.

Where did you add Line Numbers ?

mx
Pardon me for jumping in ...

trbaze, have you installed all the Office 2007 update so that you have SP2?

Also make use that you manually compile the VBA code after pasting any code or running add-in like MZtools.
Avatar of trbaze

ASKER

Yes I have the sp2 update, also the code complied fine.  I ran the program, then it started giving me the event errors.  The forms, reports and modules are all giving same errors.
Avatar of trbaze

ASKER

Now its saying VB project cannot be read.
Now, you didn't try to use the *example* code I posted did you?  That was just to show an example of how ERL can be used.

Can you upload your db ?

mx
Avatar of trbaze

ASKER

I didn't use your code.
Inventory.accdb
Do you have a backup?

I hate to say this, but the VBA project IS corrupted and I cannot open - without Access deleting all code modules.

mx
Avatar of trbaze

ASKER

Thats the problem I had.  I have a backup thats a day old, so some changes won't be there.  Why would that happen?
Avatar of trbaze

ASKER

I'm not sure if it was the add-in or not.  It was working fine until I added a Cancel as integer to an OnEnter event on a button.
"Why would that happen?"
I am 99.9987531% sure that MZTools did not do this.  I have MZTools on 4 of my systems, as well as two systems at work (A2003 and A2010) ... never ever a problem.

"it was working fine until I added a Cancel as integer to an OnEnter event on a button."

You can't do that.  The On Enter event does not contain any arguments.  Nor can any arguments be added to any built in Form or Control event.

However, you should have just gotten a Compile error immediately.  I can't possibly image how that would have resulted in this corruption.

I would send it to Wayne (http://www.everythingaccess.com/accessdatabaserepair.htm), explain what you did ... and see if he can fix it ...

mx
Whenever I have seen the VBA code get corrupted like this the database was not recoverable at all.

In the past there was an issue with the VBA editor that would corrupt the VBA code for the enter database.

This is also another good reason to split the databases. I regular work on updates in a copy of the front end. I will  import the changes into the master front end by using exporting/import objects to a text file similar to how Safe Source works.

Hopefully you are making regular backups as you go. Especially before running an toll that makes mass changes.



Avatar of trbaze

ASKER

If i were to distribute this as an MDE file that will run under access runtime, will it be able to run the erl code?
"will it be able to run the erl code?"
Definitely ... in fact, you REALLY want it in an MDE ... for possible troubleshooting later on.

mx

I totlaly agree with mx.

The last step I use just before creating my MDE/ACCDE is to add line numbers and do some code clean up.

Here is how I do it: http://www.fmsinc.com/free/newtips/vba/errorhandling/linenumber.html
Avatar of trbaze

ASKER

Thanks again for your help, I really appreciate it.