Arthur Justice
New Member
- Joined
- Aug 12, 2017
- Messages
- 4
Hello,
Excel 2010
First issue:
- form still executes even if field is left blank
- I don't want the form to execute if certain boxes are blank
- I currently have a message box that pops up, but the other fields still execute
Private Sub submitbutton_Click()
Cells(emptyrow, 1).Value = Now()
Cells(emptyrow, 2).Value = nametxt.Value
Cells(emptyrow, 3).Value = phonetxt.Value
Cells(emptyrow, 4).Value = bldgtxt.Value
Cells(emptyrow, 5).Value = roomtxt.Value
Cells(emptyrow, 6).Value = codetxt.Value
Cells(emptyrow, 8).Value = resttxt.Value
Cells(emptyrow, 9).Value = descriptionlistbox.Value
Cells(emptyrow, 10).Value = explaintxt.Value
Cells(emptyrow, 11).Value = stafftxt.Value
If nametxt.Value = "" Then
MsgBox "Please Enter the Requestor's Name", vbCritical
Me.nametxt.SetFocus
Exit Sub
Else
' code if not empty
End If
Also, is there a way to lock the cells from editing after the form is submitted? I don't want the people using the form to be able to edit the data once it is on the worksheet.
Thank you in advance for your help.
Excel 2010
First issue:
- form still executes even if field is left blank
- I don't want the form to execute if certain boxes are blank
- I currently have a message box that pops up, but the other fields still execute
Private Sub submitbutton_Click()
Cells(emptyrow, 1).Value = Now()
Cells(emptyrow, 2).Value = nametxt.Value
Cells(emptyrow, 3).Value = phonetxt.Value
Cells(emptyrow, 4).Value = bldgtxt.Value
Cells(emptyrow, 5).Value = roomtxt.Value
Cells(emptyrow, 6).Value = codetxt.Value
Cells(emptyrow, 8).Value = resttxt.Value
Cells(emptyrow, 9).Value = descriptionlistbox.Value
Cells(emptyrow, 10).Value = explaintxt.Value
Cells(emptyrow, 11).Value = stafftxt.Value
If nametxt.Value = "" Then
MsgBox "Please Enter the Requestor's Name", vbCritical
Me.nametxt.SetFocus
Exit Sub
Else
' code if not empty
End If
Also, is there a way to lock the cells from editing after the form is submitted? I don't want the people using the form to be able to edit the data once it is on the worksheet.
Thank you in advance for your help.