Your posted code works with the activesheet and is different to your actual code
Your workbook's code cannot work
Code:
Option ExplicitPrivate Sub cmdAdd_Click()
Dim LastRow As Long
With Sheets("Register")
LastRow = .Cells(.Ro.Count, "A").End(xlUp).Row + 1
'copy the data to the database
.Cells(LastRow, 1).Value = Me.txtassetname.Value
.Cells(LastRow, 2).Value = Me.txtassetid.Value
.Cells(LastRow, 3).Value = Me.txtserialnumber.Value
.Cells(LastRow, 4).Value = Me.txtassetdescription.Value
.Cells(LastRow, 5).Value = Me.txtassetdescription.Value
.Cells(LastRow, 6).Value = Me.txtassetcategory.Value
.Cells(LastRow, 7).Value = Me.txtassettype.Value
.Cells(LastRow, 8).Value = Me.txtsupplier.Value
.Cells(LastRow, 9).Value = Me.txtmanufacturer.Value
.Cells(LastRow, 10).Value = Me.txtmodel.Value
.Cells(LastRow, 11).Value = Me.txtmake.Value
.Cells(LastRow, 12).Value = Me.txtpurchasedate.Value
.Cells(LastRow, 13).Value = Me.txtpurchaseprice.Value
.Cells(LastRow, 14).Value = Me.txtlocation.Value
.Cells(LastRow, 15).Value = Me.txtlocationref.Value
.Cells(LastRow, 16).Value = Me.txtwarrantyexpirydate.Value
End With
'clear the data
With Me
.txtassetname.Value = ""
.txtassetid.Value = ""
.txtserialnumber.Value = ""
.txtassetdescription.Value = ""
.txtassetdescription.Value = ""
.txtassetcategory.Value = ""
.txtassettype.Value = ""
.txtsupplier.Value = ""
.txtmanufacturer.Value = ""
.txtmodel.Value = ""
.txtmake.Value = ""
.txtpurchasedate.Value = ""
.txtpurchaseprice.Value = ""
.txtlocation.Value = ""
.txtlocationref.Value = ""
.txtwarrantyexpirydate.Value = ""
End With
End Sub
Bookmarks