Option Explicit
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("OBN")
'find first empty row in database
iRow = ws.Range("A:AI").Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a part number
If Trim(Me.tklantnummer.Value) = "" Then
Me.tklantnummer.SetFocus
MsgBox "Voer a.u.b. de gegevens in"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.tklantnummer.Value
ws.Cells(iRow, 2).Value = Me.tvoorletters.Value
ws.Cells(iRow, 3).Value = Me.ttussenvoegsel.Value
ws.Cells(iRow, 4).Value = Me.tachternaam.Value
ws.Cells(iRow, 5).Value = Me.tstraat.Value
ws.Cells(iRow, 6).Value = Me.thuisnummer.Value
ws.Cells(iRow, 7).Value = Me.tpostcode.Value
ws.Cells(iRow, 8).Value = Me.tplaats.Value
ws.Cells(iRow, 9).Value = Me.combihuidigi.Value
ws.Cells(iRow, 10).Value = Me.tnaamhuidigi.Value
ws.Cells(iRow, 11).Value = Me.tklnrhuidigi.Value
ws.Cells(iRow, 12).Value = Me.combihuidigtv.Value
ws.Cells(iRow, 13).Value = Me.tnaamhuidigtv.Value
ws.Cells(iRow, 14).Value = Me.tklnrhuidigtv.Value
ws.Cells(iRow, 15).Value = Me.Combihuidigp.Value
ws.Cells(iRow, 16).Value = Me.tnaamhuidigp.Value
ws.Cells(iRow, 17).Value = Me.tklnrhuidigp.Value
ws.Cells(iRow, 18).Value = Me.datumact.Value
ws.Cells(iRow, 19).Value = Me.teindi.Value
ws.Cells(iRow, 20).Value = Me.teindtv.Value
ws.Cells(iRow, 21).Value = Me.teindp.Value
ws.Cells(iRow, 22).Value = Me.oact.Value
ws.Cells(iRow, 23).Value = Me.optOBN.Value
ws.Cells(iRow, 24).Value = Me.optON.Value
ws.Cells(iRow, 25).Value = Me.nummerbehoud.Value
'clear the data
Me.tklantnummer.Value = ""
Me.tvoorletters.Value = ""
Me.ttussenvoegsel.Value = ""
Me.tachternaam.Value = ""
Me.tstraat.Value = ""
Me.thuisnummer.Value = ""
Me.tpostcode.Value = ""
Me.tplaats.Value = ""
Me.combihuidigi.Value = ""
Me.tnaamhuidigi.Value = ""
Me.tklnrhuidigi.Value = ""
Me.combihuidigtv.Value = ""
Me.tnaamhuidigtv.Value = ""
Me.tklnrhuidigtv.Value = ""
Me.Combihuidigp.Value = ""
Me.tnaamhuidigp.Value = ""
Me.tklnrhuidigp.Value = ""
Me.datumact.Value = ""
Me.teindi.Value = ""
Me.teindtv.Value = ""
Me.teindp.Value = ""
Me.oact.Value = ""
Me.optOBN.Value = ""
Me.optON.Value = ""
Me.nummerbehoud.Value = ""
Me.tklantnummer.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub topdesk_Change()
topdesk.Value = "Called customer & tklantnummer.Value & for validating information. " & vbLf & _
txbVoorleters.Value & " " & txbTussenvoegsel.Value & " " & txbAchternaam.Value & "."
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Gebruik aub de Sluiten knop!"
End If
End Sub