sorry that i forgot to mention. even with RoyUK's code the textboxes dont get set to "".
I am sending you now the full code; Any suggestion is welcome.
Private Sub cmdAdd_Click()
Dim i As Integer
Dim iRow As String
Dim ws As Worksheet
Dim wsdata As Worksheet
'check for a part number
If Trim(Me.cbocode1.Value) = "" Then
Me.cbocode1.SetFocus
MsgBox "Please choose a code number", vbExclamation, "Code no missing"
Exit Sub
End If
If txttrial.Value = "1" Then
Set ws = Worksheets("Trial " & txttrial.Value)
ws.Activate
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txttrial.Value
ws.Cells(iRow, 2).Value = Me.cbocode1.Value
ws.Cells(iRow, 3).Value = Me.txtdescription1.Value
ws.Cells(iRow, 4).Value = Me.txtpercentage1.Value
ws.Cells(iRow, 5).Value = Me.txtgr1.Value
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 1).Value = Me.txttrial.Value
ws.Cells(iRow, 2).Value = Me.cbocode2.Value
ws.Cells(iRow, 3).Value = Me.txtdescription2.Value
ws.Cells(iRow, 4).Value = Me.txtpercentage2.Value
ws.Cells(iRow, 5).Value = Me.txtgr2.Value
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 1).Value = Me.txttrial.Value
ws.Cells(iRow, 2).Value = Me.cbocode3.Value
ws.Cells(iRow, 3).Value = Me.txtdescription3.Value
ws.Cells(iRow, 4).Value = Me.txtpercentage3.Value
ws.Cells(iRow, 5).Value = Me.txtgr3.Value
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 1).Value = Me.txttrial.Value
ws.Cells(iRow, 2).Value = Me.cbocode4.Value
ws.Cells(iRow, 3).Value = Me.txtdescription4.Value
ws.Cells(iRow, 4).Value = Me.txtpercentage4.Value
ws.Cells(iRow, 5).Value = Me.txtgr4.Value
If cbocode5.Value = "" Then
Dim cCont As msforms.Control
For Each cCont In Me.Controls
With cCont
Select Case TypeName(cCont)
Case "ComboBox": .Value = ""
Case TypeName(cCont) = "TextBox"
If .Tag <> "x" Then .Value = ""
Case TypeName(cCont) = "Label"
If .Name = "lblproduct" Then .Caption = ""
End Select
End With
Next cCont
Me.txttotalweight.Value = ""
Me.txttotalpercentage.Value = ""
Me.cbocode1.SetFocus
txttrial.Value = txttrial.Value + 1
Exit Sub
Bookmarks