nicolavision
New Member
- Joined
- Oct 21, 2004
- Messages
- 31
Hi
I have a command button that has the following code to it - but it's failing due to the IF Statements.
What the code should do is check the first IF statement is that's OK then move to the next IF statement. if the first statement isn't OK then run the then statement and start checking again.
I have know idea where I've gone wrong please help!
Thanks
I have a command button that has the following code to it - but it's failing due to the IF Statements.
What the code should do is check the first IF statement is that's OK then move to the next IF statement. if the first statement isn't OK then run the then statement and start checking again.
I have know idea where I've gone wrong please help!
Code:
Private Sub cmdOK_Click()
On Error GoTo Handler
If txtEmployeeNo.Value = "" And txtEmployeeNo.Visible = True Then
MsgBox "Please enter Employee Number", vbInformation, "Data Required"
txtEmployeeNo.SetFocus
Else
If txtFirstName.Value = "" And txtFirstName.Visible = True Then
MsgBox "Please enter First Name", vbInformation, "Data Required"
txtFirstName.SetFocus
Else
If txtLastName.Value = "" And txtLastName.Visible = True Then
MsgBox "Please enter Last Name", vbInformation, "Data Required"
txtLastName.SetFocus
Else
ActiveWorkbook.Sheets("User Information").Activate
Range("A1:B15").Select
Selection.Copy
Workbooks.Add
Application.DisplayAlerts = False
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.DisplayZeros = False
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
Application.CutCopyMode = False
ChDir "H:\"
ActiveWorkbook.SaveAs Filename:="H:\UserInformation.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
End If
End If
Handler:
Application.DisplayAlerts = False
ActiveWorkbook.Close
Unload Me
Application.DisplayAlerts = False
Sheet1.Visible = xlSheetHidden
ActiveWorkbook.Sheets("Standard Expense Claim").Activate
Range("A5").Select
End Sub
Thanks