I have the following code which updates a database. I would like to ensure that when the user hits the SUBMIT button they are not accidentally adding blank information to the database. Basically, if there is no name entered, I would like the user to receive an error and not be permitted to add empty values to the database.
Private Sub cmdSubmit_Click()
Dim lastrow As Long
With Sheets("DATABASE")
lastrow = .Range("A2").End(xlDown).Row
.Cells(lastrow + 1, 1).Value = txtLastName.Text & ", " & txtFirstName.Text
.Cells(lastrow + 1, 2).Value = txtCCN.Text
.Cells(lastrow + 1, 3).Value = txtDateofhire.Text
.Cells(lastrow, 4).Resize(1, 6).Copy .Cells(lastrow + 1, 4)
.Select
.Cells(lastrow, 1).Select
End With
Application.CutCopyMode = False
txtFirstName = ""
txtLastName = ""
txtCCN = ""
txtDateofhire = ""
End Sub
Bookmarks