Hello,
I have a code that I use to retrieve work orders into the original template. The user enters the job number they wish to retrieve, very simple and works really good. However I need to add an error handler so if they enter a job number that does not exist that it displays a message telling the user that the job number they are trying to retrieve does not exist.
This is the code I have...
Code
Private Sub cmdRetrieveMiscWO_Click()
Dim wb As Workbook
Application.ScreenUpdating = False
Set wb = Workbooks.Open("C:[URL="file://\\General\Work"]\Work[/URL] Orders\Miscellaneous\JB-" & Me.txtJobNo & ".xlsx", True, True)
With ThisWorkbook.Worksheets("MiscWO")
.Range("E5:F5").Value = wb.Worksheets(1).Range("E5:F5").Value
.Range("A7:G7").Value = wb.Worksheets(1).Range("A7:G7").Value
.Range("A9:G9").Value = wb.Worksheets(1).Range("A9:G9").Value
.Range("A11:G11").Value = wb.Worksheets(1).Range("A11:G11").Value
.Range("A16:A18").Value = wb.Worksheets(1).Range("A16:A18").Value
.Range("A22:G48").Value = wb.Worksheets(1).Range("A22:G48").Value
.Range("D1").Value = wb.Worksheets(1).Range("D1").Value
End With
wb.Close False
Set wb = Nothing
Application.ScreenUpdating = True
Unload Me
End Sub
Display More