Syntax Error
Mama Correct kara....
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for emp Name
If Trim(Me.txtname.Value) = "" Then
Me.txtname.SetFocus
MsgBox "Please enter EMP Name"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtname.Value
ws.Cells(iRow, 2).Value = Me.txtid.Value
ws.Cells(iRow, 3).Value = IIf(Val(Mid(Me.txtid.Value, 3, 3)) > 500, "Female", "Male")
ws.Cells(iRow, 4).Value = Left(Me.txtid.Value, 2) + 1900
ws.Cells(iRow, 5).Value = IIf(Val(Mid(Me.txtid.Value, 3, 3)) > 500, Val(Mid(Me.txtid.Value, 3, 3)) - 500, Val(Mid(Me.txtid.Value, 3, 3)))
'clear the data
Me.txtname.Value = ""
Me.txtid.Value = ""
Me.txtname.SetFocus
End Sub
Private Sub cmdExit_Click()
x = MsgBox("Are you sure you want to exit", vbYesNo, "Sure")
If x = vbYes Then
Unload Me
End If
End Sub
Any Way nice Code........
Thanks......