PDA

View Full Version : Solved: Error Handler Routine Problem



phendrena
11-18-2008, 03:03 AM
Hi,

I've setup an error handler routine that always runs.
I can't work out why. I'm using a shared workbook.
When the workbook is saved if someone else is saving the workbook at the same time then the error handler routine will run. However the routine always runs. I've unshared the workbook and tried saving it by myself and it generates the error.

Any suggestions?

Private Sub cmdUpdate_Click()
' Check to see if Who Called has been completed
If Trim(Me.cboWhoCalled.Value) = "" Then
Me.cboWhoCalled.SetFocus
MsgBox "Please complete the Who Called field!"
Exit Sub
End If

' Check to see if Nature Of Call has been completed
If Trim(Me.cboReason.Value) = "" Then
Me.cboReason.SetFocus
MsgBox "Please complete the Nature Of Call field!"
Exit Sub
End If

Call SendGeneralEmail

ActiveWorkbook.Save

On Error GoTo ErrHandler


Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("InboundData")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtDate.Value
ws.Cells(iRow, 2).Value = Me.txtCM.Value
ws.Cells(iRow, 3).Value = Me.cboWhoCalled.Value
ws.Cells(iRow, 4).Value = Me.txtDealerNo.Value
ws.Cells(iRow, 5).Value = Me.txtContact.Value
ws.Cells(iRow, 6).Value = Me.txtDealerName.Value
ws.Cells(iRow, 7).Value = Me.cboScheme.Value
ws.Cells(iRow, 8).Value = Me.cboReason.Value
ws.Cells(iRow, 9).Value = Me.txtComments.Value
ws.Cells(iRow, 10).Value = Me.cboSubject.Value

'clear the data
Me.txtDate.Value = Format(Date, "yyyy/mm/dd")
Me.txtCM.Value = Application.UserName
Me.cboWhoCalled.Value = ""
Me.txtContact.Value = ""
Me.txtDealerNo.Value = ""
Me.txtDealerName.Value = ""
Me.cboScheme.Value = ""
Me.cboReason.Value = ""
Me.txtComments.Value = ""
Me.cboSubject.Value = ""
Me.txtCM.SetFocus

Unload Me

ErrHandler:
MsgBox "Another user is trying to save the workbook. Automatically retrying in 5 seconds."
Application.Wait Now + TimeValue("0:00:05")
ActiveWorkbook.Save
Resume Next

End Sub

Thanks,

Bob Phillips
11-18-2008, 03:10 AM
Isn't it just a missing



Exit Sub


just prior to the ErrHandler label?

phendrena
11-18-2008, 03:14 AM
Isn't it just a missing



Exit Sub


just prior to the ErrHandler label?

My utter noobishness show again!!

Thanks xld :beerchug: