Hi All,
I have a form with the following code:
Code:
' PointsUsed tab (on form)
Private Sub ComboClockuse_Change()
Dim lblemplnameUSE As String
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Totals")
Dim Ret_Type As Integer
If Trim(Me.ComboClockUse.Value) = "" Then
Me.ComboClockUse.SetFocus
Exit Sub
End If
'if vlookup encounters an error
On Error GoTo ErrHandler:
'Vlookup to find employee name
Me.lblemplnameUSE = Application.WorksheetFunction.VLookup(ComboClockUse.Value, sheet.Range("EmpClock"), 2, False)
Me.lblAvailPts = Application.WorksheetFunction.VLookup(ComboClockUse.Value, sheet.Range("AvailPts"), 11, False)
Exit Sub
ErrHandler:
Ret_Type = Msgbox("Clock Number not found. Click OK to enter new employee", vbOKCancel, "Invalid Clock Number")
' if ok or cancel buttons are pressed
Select Case Ret_Type
Case 1 'ok
Unload Me
Copper_Crusaders_Points.Show
MultiPage1.Value = 2
Case 2 'cancel
Unload Me
Copper_Crusaders_Points.Show
MultiPage1.Value = 1
End Select
Exit sub
End Sub
My problem is that no matter which option button is selected, all I get is the results for Case 2 and then the vlookup doesn't work. So if the user wants to cancel and reenter a new clock number they have to close the form and manually reopen it.
this was working until I decided I wanted a vbOKCancel instead of a VbOkOnly.
What should I do?
Thanks,
Angelina
PS I uploaded a sample and provided a link to onedrive for those who would like to take a look at the whole project.
https://onedrive.live.com/?cid=B3C47...091AE166%21105