stephenlecompte
07-20-2003, 08:37 AM
I have two control buttons with the following code:
Private Sub cmdBook_Click()
On Error GoTo Err_cmdBook_Click
'
'
'The in between is other codes that processes user information
'
Exit_cmdBook_Click:
Exit Sub
Err_cmdBook_Click:
ERROR = Err.Description
ERRWHERE = "@ New Order section"
Call Error_Action
End Sub
Call Error Action saves the error in a text file! I like this option because it allows me to review any errors made by the user on the network. It not only saves the type of error but also who made it and the data they typed in the text boxes before they made it. My problem is that I want this feature in my entire program - Not just those control buttons! My problem is that I have a lot of option buttons and call routines, plus other Private Sub commands throughout my program. (66 Private Sub commands in all) How can I make this program do the above no matter what the command? I'm thinking its in my Module1 - that I made to declare all my public variables but I'm not sure on the format and correct code? Please, please, please, help me! Thanks, Stephen
P.S. Another tip - before you click Submit New Thread and you have long thread always copy all of your message to the clipboard...just in case!
Thinker
07-20-2003, 10:29 AM
Unhandled errors will trickle up to a higher and higher level until they
reach the top of the call stack. If they haven't been handled by then
they will abort the program. Since you want to know the location each
error occurred, you have no choice but to add error handling to each sub
where one could occur.
stephenlecompte
07-21-2003, 07:14 AM
Unhandled errors will trickle up to a higher and higher level until they
reach the top of the call stack. If they haven't been handled by then
they will abort the program. Since you want to know the location each
error occurred, you have no choice but to add error handling to each sub
where one could occur.
Just curious but what if I didn't want to know the location of the error - Based on the data entry of the user-I created a seperate file that reports everything the user entered. Based on that data and the error message - I could tell where the error occurred in the program or what they were in the midst of! If I could include this error safety feature in all of the program without going to each sub- is it possible?
Thinker
07-21-2003, 07:36 AM
As I already said, by the time the error has trickled up to the top of the
call stack, you won't have anyway of knowing anything including any
data the user was entering. All you will have is the err object with the
number and description.
stephenlecompte
07-21-2003, 12:07 PM
even if I did the following:
Private Sub Error_Action()
MsgBox "Order is not being processed - please adjust some of your data entry! Also, please Yahoo Messenger (or email) - Stephen LeCompte Jr. (slecompte@centralsystems.com) about a possible error!"
Close #1
Open ERRORTXT For Append As #1
Print #1, Err, ERROR, ERRWHERE, Adodc1.Recordset!BKBY, Date, Time, "@ cmdBook"
Close #1
Open ERRDATATXT For Append As #1
Print #1, Err, Date, Time, txtBox(4).Text 'who booked the order
Print #1, "Last Name: "; txtBox(0).Text; " , "; "First Name: "; txtBox(1).Text
Print #1, "Phone: "; txtBox(2).Text; " & "; "Phone1: "; txtBox(3).Text
Print #1, "OA Order: ";: If OA.Value = 1 Then Print #1, "Yes"; " "; Else Print #1, "NO "" ";
Print #1, "INTL: ";: If INTL.Value = 1 Then Print #1, "Yes"; " "; Else Print #1, "NO "; " ";
Print #1, "MILITARY: ";: If military.Value = 1 Then Print #1, "Yes" Else Print #1, "NO "
Print #1, "LOCAL: ";: If Local1.Value = 1 Then Print #1, "Yes"; " "; Else Print #1, "NO ";
Print #1, "Own: ";: If Own.Value = True Then Print #1, "Yes"; " "; Else Print #1, "NO ";
Print #1, "Mayflower: ";: If Mayf.Value = True Then Print #1, "Yes"; " " Else Print #1, "NO "
Print #1, "ORIG City: "; txtBox(5).Text; " "; txtBox(6).Text; " "; txtBox(7).Text
Print #1, "DEST City: "; txtBox(16).Text; " "; txtBox(10).Text; " "; txtBox(9).Text
Print #1, "SALESPERSON: "; SALES; " "; txtBox(14).Text; " "; txtBox(12).Text; " WEIGHT: "; txtBox(13).Text
Print #1, "AGENCY/GENERATE/YEAR: "; txtBox(8); "/"; txtBox(11); "/"; txtBox(15); " "; Adodc1.Recordset!Order
Close #1
End Sub
Once an error is submitted it saves everything that was in my textboxes and values of the option boxes. Sure I could have the program end right there...but at least I knew where. My problem is that I don't know what a call stack is. Sorry, thinker.
stephenlecompte
07-21-2003, 12:08 PM
could I please have this thread deleted - after today!
Thinker
07-21-2003, 01:07 PM
Look, in your routine you use what I assume is a globally declared
variable ERRWHERE. How did it get set? In your first post you set it in
an error handler specific to a sub. Then you asked if there was a way to
avoid having to have an error handler in each sub. So if you don't have
that there, how do you expect ERRWHERE to know anything?
We don't delete threads here unless they are junk. The idea of this free
forum is to provide help both by answering questions and to have a
searchable database where others can find answers by just searching.