I have a Compile error:
Invalid or unqualified reference
and can't find the problem
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets(",")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1)
.End(xlUp).Offset(1, 0).Row _
'check for a Category
If Trim(Me.cboCategory.Value) = "" Then
Me.cboCategory.SetFocus
MsgBox "Please Select a Category"
Exit Sub
End If
'check for a Product
If Trim(Me.txtProduct.Value) = "" Then
Me.cboCategory.SetFocus
MsgBox "Please Enter a Product Description"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtProduct.Value
ws.Cells(iRow, 2).Value = Me.cboUnit.Value
ws.Cells(iRow, 3).Value = Me.txtPrice.Value
ws.Cells(iRow, 4).Value = Me.txtLabour.Value
'clear the data
Me.cboCategory.Value = ""
Me.txtProduct.Value = ""
Me.cboUnit.Value = ""
Me.txtPrice.Value = ""
Me.txtLabour.Value = ""
Me.cboCategory.SetFocus
End Sub
Bookmarks