View Full Version : Error 0


DataMiner
08-07-2007, 02:56 PM
Hi,
Any idea why my logerror function is intermittently logging err.description = {blank} and err.num=0, see stuff in bold near end of code below. I can't figure out why it would even get to the error handler without having an error number and description. Any ideas?

Private Sub JobComplete_AfterUpdate()
Dim strSetupName As String, dTime As Date
Dim ActualRunHrs As Double, StdHrs As Double
If errorhandlingon Then On Error GoTo ErrHandle 'added 11/13/06

If JobComplete = False Then
If MsgBox3("You are changing a completed job back to uncomplete. Are you sure???", "OK,Cancel", "Un-complete this job?", , , Normal, 30000, 2, True) = 2 Then Me.JobComplete = True
Form_Current
Exit Sub
End If


If (SMTSideQty = 2 And IsNull(ActualFinishTime2)) Or IsNull(ActualFinishTime1) Then
msgboxautoclosedialog "You must enter start and completion times!", "Missing times", 30000
JobComplete = False
Text22.SetFocus
Exit Sub
End If

If ActualRunQty <> RunQty And IsNull(ctlComments.Value) Then
msgboxautoclosedialog "You've entered a run quantity different from the scheduled run qty. Please explain in the 'reason / comments' area.", "Enter a reason", 30000
ctlComments.SetFocus
strSetupName = DLookup("smtsetupname", "Latestrevmaster1", "Noun='" & Me.Noun & "'")

Me.HrsPerRun = Me.ActualRunQty * DLookup("runsecsperunit", "SMT_ABC", "smtsetupname='" & strSetupName & "'") / 3600
JobComplete = False
Exit Sub
End If

dTime = NowCorrected()
If Text22.Value > dTime Or Text24.Value > dTime Or Text46.Value > dTime Or Text47.Value > dTime Then
msgboxautoclosedialog "Time can't be in the future!", "Time can't be in the future", 60000
JobComplete = False
Text22.SetFocus

Exit Sub
End If

If ActualStartTime1 > ActualFinishTime1 Or ActualStartTime2 > ActualFinishTime2 Or (Not IsNull(ActualFinishTime1) And IsNull(ActualStartTime1)) Or (Not IsNull(ActualFinishTime2) And IsNull(ActualStartTime2)) Then
msgboxautoclosedialog "Completion time must be later than start time!", "Completion time earlier than start time", 15000
'
JobComplete = False
Text22.SetFocus
Exit Sub
End If

If IsNull(ActualRunQty) Then
msgboxautoclosedialog "You must enter a run quantity!", "No run qty", 15000

JobComplete = False
Text19.SetFocus
Exit Sub
End If



If ActualRunQty = 0 Then
If MsgBox3("You are completing this job with a run qty of zero. Is this correct?", "Yes,No", "Run Qty of zero?", , , Normal, 30000, 2) = 2 Then
JobComplete = False
Text19.SetFocus
Exit Sub
End If
End If
'ok to here
If ActualRunQty > 2000 Then
If MsgBox3("You are completing this job with a run qty of " & Me.RunQty.Value & ". Run qty's above 2000 are rare. Is this correct?", "Yes,No", "Large Run Qty?", , , Normal, 30000, 2) = 2 Then
JobComplete = False
Text19.SetFocus
Exit Sub
End If
End If

ActualRunHrs = 24 * (ActualFinishTime1 - ActualStartTime1 + Nz(ActualFinishTime2, 0) - Nz(ActualStartTime2, 0))
'changed 10/3/06
StdHrs = DFirst("runtimemultiplier", "constants", "valuestream='" & Me.SMTLine.Value & "'") * Nz(DLookup("totalsecsperunit", "machinetimesperunit", "noun='" & Me.Noun & "'"), 60) * Me.ActualRunQty / 3600

If ActualRunHrs > StdHrs And (IsNull(Me.prob) Or Me.prob = 0) Then
msgboxautoclosedialog "Run time exceeds standard time. You must enter a problem code." & vbCrLf & _
"Standard time: " & getelapsedtime(StdHrs / 24) & vbCrLf & _
"Actual time: " & getelapsedtime(ActualRunHrs / 24), "Enter a problem code", 30000
JobComplete = False
Me.prob.SetFocus
Exit Sub
End If

If IsNull(Me.JobCompleteOperator) Then
msgboxautoclosedialog "You must enter an employee ID for the person completing the job", "Enter Emp ID", 30000
JobComplete = False
Me.JobCompleteOperator.SetFocus
Exit Sub
End If
'DoCmd.GoToRecord , , acNext
'changed 8/7/07
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_Current
Exit Sub
ErrHandle:
Select Case Err.Number
Case 2105 'cant go to next record, must already be at last record, so go to first instead
DoCmd.GoToRecord , , acFirst

Case Else
msgboxautoclosedialog "Error #" & Err.Number & " :" & Err.Description & vbCrLf & _
"Please notify Vickie.", , 30000
LogError Err.Description, "Actuals:JobComplete AfterUpdate", Err.Number
End Select
End Sub

RuralGuy
08-07-2007, 04:13 PM
How can you read it without any indenting?
Private Sub JobComplete_AfterUpdate()
Dim strSetupName As String, dTime As Date
Dim ActualRunHrs As Double, StdHrs As Double
If errorhandlingon Then On Error GoTo ErrHandle 'added 11/13/06

If JobComplete = False Then
If MsgBox3("You are changing a completed job back to uncomplete. Are you sure???", "OK,Cancel", "Un-complete this job?", , , Normal, 30000, 2, True) = 2 Then Me.JobComplete = True
Form_Current
Exit Sub
End If

If (SMTSideQty = 2 And IsNull(ActualFinishTime2)) Or IsNull(ActualFinishTime1) Then
msgboxautoclosedialog "You must enter start and completion times!", "Missing times", 30000
JobComplete = False
Text22.SetFocus
Exit Sub
End If

If ActualRunQty <> RunQty And IsNull(ctlComments.Value) Then
msgboxautoclosedialog "You've entered a run quantity different from the scheduled run qty. Please explain in the 'reason / comments' area.", "Enter a reason", 30000
ctlComments.SetFocus
strSetupName = DLookup("smtsetupname", "Latestrevmaster1", "Noun='" & Me.Noun & "'")

Me.HrsPerRun = Me.ActualRunQty * DLookup("runsecsperunit", "SMT_ABC", "smtsetupname='" & strSetupName & "'") / 3600
JobComplete = False
Exit Sub
End If

dTime = NowCorrected()
If Text22.Value > dTime Or Text24.Value > dTime Or Text46.Value > dTime Or Text47.Value > dTime Then
msgboxautoclosedialog "Time can't be in the future!", "Time can't be in the future", 60000
JobComplete = False
Text22.SetFocus

Exit Sub
End If

If ActualStartTime1 > ActualFinishTime1 Or ActualStartTime2 > ActualFinishTime2 Or (Not IsNull(ActualFinishTime1) And IsNull(ActualStartTime1)) Or (Not IsNull(ActualFinishTime2) And IsNull(ActualStartTime2)) Then
msgboxautoclosedialog "Completion time must be later than start time!", "Completion time earlier than start time", 15000
'
JobComplete = False
Text22.SetFocus
Exit Sub
End If

If IsNull(ActualRunQty) Then
msgboxautoclosedialog "You must enter a run quantity!", "No run qty", 15000

JobComplete = False
Text19.SetFocus
Exit Sub
End If

If ActualRunQty = 0 Then
If MsgBox3("You are completing this job with a run qty of zero. Is this correct?", "Yes,No", "Run Qty of zero?", , , Normal, 30000, 2) = 2 Then
JobComplete = False
Text19.SetFocus
Exit Sub
End If
End If
'ok to here
If ActualRunQty > 2000 Then
If MsgBox3("You are completing this job with a run qty of " & Me.RunQty.Value & ". Run qty's above 2000 are rare. Is this correct?", "Yes,No", "Large Run Qty?", , , Normal, 30000, 2) = 2 Then
JobComplete = False
Text19.SetFocus
Exit Sub
End If
End If

ActualRunHrs = 24 * (ActualFinishTime1 - ActualStartTime1 + Nz(ActualFinishTime2, 0) - Nz(ActualStartTime2, 0))
'changed 10/3/06
StdHrs = DFirst("runtimemultiplier", "constants", "valuestream='" & Me.SMTLine.Value & "'") * Nz(DLookup("totalsecsperunit", "machinetimesperunit", "noun='" & Me.Noun & "'"), 60) * Me.ActualRunQty / 3600

If ActualRunHrs > StdHrs And (IsNull(Me.prob) Or Me.prob = 0) Then
msgboxautoclosedialog "Run time exceeds standard time. You must enter a problem code." & vbCrLf & _
"Standard time: " & getelapsedtime(StdHrs / 24) & vbCrLf & _
"Actual time: " & getelapsedtime(ActualRunHrs / 24), "Enter a problem code", 30000
JobComplete = False
Me.prob.SetFocus
Exit Sub
End If

If IsNull(Me.JobCompleteOperator) Then
msgboxautoclosedialog "You must enter an employee ID for the person completing the job", "Enter Emp ID", 30000
JobComplete = False
Me.JobCompleteOperator.SetFocus
Exit Sub
End If
'DoCmd.GoToRecord , , acNext
'changed 8/7/07
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_Current
Exit Sub
ErrHandle:
Select Case Err.Number
Case 2105 'cant go to next record, must already be at last record, so go to first instead
DoCmd.GoToRecord , , acFirst

Case Else
msgboxautoclosedialog "Error #" & Err.Number & " :" & Err.Description & vbCrLf & _
"Please notify Vickie.", , 30000
LogError Err.Description, "Actuals:JobComplete AfterUpdate", Err.Number
End Select
End Sub

DataMiner
08-07-2007, 05:37 PM
Hmm, what do you mean, "without any indenting"? When I view it, there is indenting to clarify the if-then statements. It looks pretty readable to me (but then again, I wrote it....) What would you have me do to make it more readable?

DataMiner
08-07-2007, 05:41 PM
OH... now I see that you have quite possibly added the indenting for me!!! How embarrassing! Well.... thanks!

RuralGuy
08-07-2007, 06:16 PM
OH... now I see that you have quite possibly added the indenting for me!!! How embarrassing! Well.... thanks!Thanks to a free add-in called Smart Indenter (http://www.oaltd.co.uk/Indenter/IndentPage.asp). Are you running the Form's Current event in this sub? If so, what code is in the Current event that you are trying to execute?

DataMiner
08-08-2007, 10:13 AM
Yes, I am running the form's on_current event:
Private Sub Form_Current()
If errorhandlingon Then On Error GoTo ErrHandle
If JobComplete = True Then
prob.Enabled = False
Text19.Enabled = False
JobCompleteOperator.Enabled = False
ctlComments.Enabled = False

Else
prob.Enabled = True
Text19.Enabled = True
JobCompleteOperator.Enabled = True
ctlComments.Enabled = True
End If





Exit Sub
ErrHandle: 'added 8/30/06
msgboxautoclosedialog "Error #" & Err.Number & ": " & Err.Description & vbCrLf & _
"Please notify Vickie!", "Error", 60000
LogError Err.Description, "Form Actuals On_current", Err.Number

End Sub

PS-- About indenting, I will definitely take a look at the add-in. Meanwhile, my code looks nicely indented when I copy it into this post, but when I preview the post the indenting is gone....

RuralGuy
08-08-2007, 10:26 AM
Use the Code tags rather than the quote tags to preserve the indenting. It is the Octothorp "#" in the tool bar. It is a better practice to make a SubRoutine for the CurrentEvent code you posted and call that Sub from the Current Event and your JobComplete_AfterUpdate event rather that involking the Current event out of sequence. There could easily be other behind the scenes code associated with these Form events that is not exposed to you and you would not want to run.

DataMiner
08-08-2007, 01:12 PM
Thanks, Will try using a subroutine rather than using form_current, and see how it goes.

RuralGuy
08-08-2007, 01:19 PM
Let us know how you make out.

DataMiner
08-15-2007, 08:55 AM
I changed to using a subroutine rather than calling the CurrentEvent directly. Still getting the same error message:
err.description = {blank} and err.num=0

Any other ideas?

RuralGuy
08-15-2007, 09:05 AM
From a code page, try setting Tools>Options...>General Tab Break on All Errors and see if you can pin it down. You may have to walk the Call Stack to see how you got there.