hi ... I have made a user form that adds to a list in my database..... form works great except for one thing..... there are two input boxes one for materials and one for price... it is set so if i enter a price and not a material then click add a msg appears telling me to enter a material..... but i also want to do the opposite.... if i enter a material and not a price i need a msg box to appear saying i need to insert a price... any help on this would be great
Private Sub CMDADD_click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("LISTS")
'find first empty row in database
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for material
If Trim(Me.TXTMAT.Value) = "" Then
Me.TXTMAT.SetFocus
MsgBox "Please Enter a Material"
Exit Sub
End If
'copy the data to the database
ws.Cells(irow, 1).Value = Me.TXTMAT.Value
ws.Cells(irow, 2).Value = Me.TXTPRICE.Value
'clear the data
Me.TXTMAT.Value = ""
Me.TXTPRICE.Value = ""
Me.TXTMAT.SetFocus
End Sub
Private Sub CMDADD_click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("LISTS")
'find first empty row in database
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for material
If Trim(Me.TXTMAT.Value) = "" Then
Me.TXTMAT.SetFocus
MsgBox "Please Enter a Material"
Exit Sub
End If
'copy the data to the database
ws.Cells(irow, 1).Value = Me.TXTMAT.Value
ws.Cells(irow, 2).Value = Me.TXTPRICE.Value
'clear the data
Me.TXTMAT.Value = ""
Me.TXTPRICE.Value = ""
Me.TXTMAT.SetFocus
End Sub