Could you please check my code

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

I have an error routine that I got from Allen Brown and I'm trying to add to
it so I can get a better description. The problem is that I'm getting an
error from it. Here is the code

On Error GoTo {PROCEDURE_NAME}_Error

{PROCEDURE_BODY}

On Error GoTo 0
Exit {PROCEDURE_TYPE}

{PROCEDURE_NAME}_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
{PROCEDURE_NAME} of {MODULE_TYPE} {MODULE_NAME}"
Err.Description = Err.Description & " In Procedure " & "{PROCEDURE_NAME}
of {MODULE_TYPE} {MODULE_NAME}"
Call LogError(Err.Number, Err.Description)

I believe the error is in the "Err.Description" line because the syntax may
not be right.

Your help would be appreciated. Thank you for reading my post.
 
J

John Spencer

Try changing this to
Dim vDesc as String

vDesc = Err.Description & " In Procedure " & "{PROCEDURE_NAME}
of {MODULE_TYPE} {MODULE_NAME}"
Call LogError(Err.Number, vDesc)


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
A

Afrosheen via AccessMonster.com

Thanks for helping me out John.
I'm getting a error: Compile Error: Argument not optional.

It was happening on the Call LogError line.


John said:
Try changing this to
Dim vDesc as String

vDesc = Err.Description & " In Procedure " & "{PROCEDURE_NAME}
of {MODULE_TYPE} {MODULE_NAME}"
Call LogError(Err.Number, vDesc)

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
I have an error routine that I got from Allen Brown and I'm trying to add to
it so I can get a better description. The problem is that I'm getting an
[quoted text clipped - 19 lines]
Your help would be appreciated. Thank you for reading my post.
 
J

John Spencer

I don't have Allen's code here. How many arguments is it expecting?
Apparently more than you are giving it.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Thanks for helping me out John.
I'm getting a error: Compile Error: Argument not optional.

It was happening on the Call LogError line.


John said:
Try changing this to
Dim vDesc as String

vDesc = Err.Description & " In Procedure " & "{PROCEDURE_NAME}
of {MODULE_TYPE} {MODULE_NAME}"
Call LogError(Err.Number, vDesc)

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
I have an error routine that I got from Allen Brown and I'm trying to add to
it so I can get a better description. The problem is that I'm getting an
[quoted text clipped - 19 lines]
Your help would be appreciated. Thank you for reading my post.
 
J

JimBurke via AccessMonster.com

I believe you need a third argument, which is supposed be the name of the
procedure the error occurred in. So if the name of your subroutine or
function that has the call to LogError is MyFunction, it would be

Call LogError(Err.Number, Err.Description, "MyFunction")
Thanks for helping me out John.
I'm getting a error: Compile Error: Argument not optional.

It was happening on the Call LogError line.
Try changing this to
Dim vDesc as String
[quoted text clipped - 15 lines]
 
J

JimBurke via AccessMonster.com

FYI, if you right click on a function or subroutine name (any routine that is
defined in your application, not routines native to Access ) when in the VBA
code window, one of the options you get is 'Definition'. If you click on that,
it will bring you to the beginning of that routine. You can then look at the
routine's code, including the argument list. Very handy for debugging issues.
Right clicking in the code window also has an option 'Last Position' which
will bring you back to where you were in the code before you got to your
current place in the code. So if you go to a routine using 'Definition', you
can use 'Last Position' to go back to where the call to the routine was.
Thanks for helping me out John.
I'm getting a error: Compile Error: Argument not optional.

It was happening on the Call LogError line.
Try changing this to
Dim vDesc as String
[quoted text clipped - 15 lines]
 
A

Afrosheen via AccessMonster.com

Thanks fellas. It looks like it needed the third argument because it looks
like it's working.

Thanks again. I'll check it out more and get back to you.

FYI, if you right click on a function or subroutine name (any routine that is
defined in your application, not routines native to Access ) when in the VBA
code window, one of the options you get is 'Definition'. If you click on that,
it will bring you to the beginning of that routine. You can then look at the
routine's code, including the argument list. Very handy for debugging issues.
Right clicking in the code window also has an option 'Last Position' which
will bring you back to where you were in the code before you got to your
current place in the code. So if you go to a routine using 'Definition', you
can use 'Last Position' to go back to where the call to the routine was.
Thanks for helping me out John.
I'm getting a error: Compile Error: Argument not optional.
[quoted text clipped - 6 lines]
 
A

Afrosheen via AccessMonster.com

Sorry for the slow response. I've been busy.

I found the problem and your were right.

Thanks
Thanks fellas. It looks like it needed the third argument because it looks
like it's working.

Thanks again. I'll check it out more and get back to you.
FYI, if you right click on a function or subroutine name (any routine that is
defined in your application, not routines native to Access ) when in the VBA
[quoted text clipped - 11 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top