Rich (BB code):
Option Explicit
Sub Reset() <- F8 ERROR
Dim iRow As Long
iRow = [Counta (Database!A:A)] ' identifying the last row <- F8 ERROR
With frmForm
.txtPVnr.Value = ""
.txtDatum.Value = ""
.txtVerdachte.Value = ""
.txtBedrijf.Value = ""
.cmbPost.Clear
.cmbPost.AddItem "post1"
.cmbPost.AddItem "post2"
.cmbPost.AddItem "post3"
.cmbLocatie.Clear
.cmbLocatie.AddItem "locatie1"
.cmbLocatie.AddItem "locatie2"
.cmbLocatie.AddItem "locatie3"
.optJa1.Value = False
.optNee1.Value = False
.cmbOvertreding.Clear
.cmbOvertreding.AddItem "fout1"
.cmbOvertreding.AddItem "fout2"
.cmbOvertreding.AddItem "fout3"
.txtGewicht.Value = ""
.txtTelling.Value = ""
.txtBoete.Value = ""
.cmbBevinding.Clear
.cmbBevinding.AddItem "overtreding1"
.cmbBevinding.AddItem "overtreding2"
.cmbBevinding.AddItem "overtreding3"
.cmbOpslagplaats.Clear
.cmbOpslagplaats.AddItem "opslag1"
.cmbOpslagplaats.AddItem "opslag2"
.cmbOpslagplaats.AddItem "opslag3"
.cmbVerbalisant1.Clear
.cmbVerbalisant1.AddItem "person1"
.cmbVerbalisant1.AddItem "person2"
.cmbVerbalisant1.AddItem "person3"
.cmbVerbalisant2.Clear
.cmbVerbalisant1.AddItem "person1"
.cmbVerbalisant1.AddItem "person2"
.cmbVerbalisant1.AddItem "person3"
.cmbVerbalisant3.Clear
.cmbVerbalisant1.AddItem "person1"
.cmbVerbalisant1.AddItem "person2"
.cmbVerbalisant1.AddItem "person3"
.cmbVerbalisant4.Clear
.cmbVerbalisant1.AddItem "person1"
.cmbVerbalisant1.AddItem "person2"
.cmbVerbalisant1.AddItem "person3"
.optJa2.Value = False
.optNee2.Value = False
.txtHoofdkantoor.Value = ""
.txtOM.Value = ""
.txtOpmerking.Value = ""
.lstDatabase.ColumnCount = 22
.lstDatabase.ColumnHeads = True
.lstDatabase.ColumnWidths = "30,30,30,60,60,50,50,30,75,40,40,40,75,75,75,75,75,75,30,40,40,150"
If iRow > 1 Then
.lstDatabase.RowSource = "Database!A2:U" & iRow
Else
.lstDatabase.RowSource = "Database!A2:U2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database") 'assign the worksheet name to the defined worksheet variable Sh
iRow = [Counta (Database!A:A)] + 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = frmForm.txtPVnr.Value
.Cells(iRow, 3) = frmForm.txtDatum.Value
.Cells(iRow, 4) = frmForm.txtVerdachte.Value
.Cells(iRow, 5) = frmForm.txtBedrijf.Value
.Cells(iRow, 6) = frmForm.cmbPost.Value
.Cells(iRow, 7) = frmForm.cmbLocatie.Value
.Cells(iRow, 8) = IIf(frmForm.optJa1.Value = True, "Ja", "Nee")
.Cells(iRow, 9) = frmForm.cmbOvertreding.Value
.Cells(iRow, 10) = frmForm.txtGewicht.Value
.Cells(iRow, 11) = frmForm.txtTelling.Value
.Cells(iRow, 12) = frmForm.txtBoete.Value
.Cells(iRow, 13) = frmForm.cmbBevinding.Value
.Cells(iRow, 14) = frmForm.cmbVerbalisant1.Value
.Cells(iRow, 15) = frmForm.cmbVerbalisant2.Value
.Cells(iRow, 16) = frmForm.cmbVerbalisant3.Value
.Cells(iRow, 17) = frmForm.cmbVerbalisant4.Value
.Cells(iRow, 18) = frmForm.cmbOpslagplaats.Value
.Cells(iRow, 19) = IIf(frmForm.optJa2.Value = True, "Ja", "Nee")
.Cells(iRow, 20) = frmForm.txtHoofdkantoor.Value
.Cells(iRow, 21) = frmForm.txtOM.Value
.Cells(iRow, 22) = frmForm.txtOpmerking.Value
End With
End Sub
Public Sub Show_Form()
frmForm.Show <- F8 ERROR
End Sub
______________________________________
Option Explicit
Private Sub cmdReset_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want ot reset the form?", vbYesNo + vbInformation, "Confirmation")
If msgValue = vbNo Then Exit Sub
Call Reset
End Sub
Private Sub cmdSubmit_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want ot save the data?", vbYesNo + vbInformation, "Confirmation")
If msgValue = vbNo Then Exit Sub
Call Submit
Call Reset
End Sub
Private Sub UserForm_Initialize() <- F8 ERROR
Call Reset <- F8 ERROR
End Sub