LilMyers2010
New Member
- Joined
- Jan 8, 2019
- Messages
- 1
Below is the coding I have that currently functions almost flawlessly!
I need the Msg windows to send the user back to the form to finish entering the data required. As it is now the msg box will appear however when you click ok it just proceeds forward without even giving the option to add the data. Also when the checkbox is checked the tbAddress field autofills (this is working) but I need the tbCity, tbState, tbZip and tbEmail fields to not be required.
TIA
I need the Msg windows to send the user back to the form to finish entering the data required. As it is now the msg box will appear however when you click ok it just proceeds forward without even giving the option to add the data. Also when the checkbox is checked the tbAddress field autofills (this is working) but I need the tbCity, tbState, tbZip and tbEmail fields to not be required.
TIA
Code:
If tbName.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer Name"
tbName.SetFocus
End If
If tbAddress.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer Address"
tbAddress.SetFocus
End If
If lpu.Value = False And tbCity.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer City"
tbCity.SetFocus
End If
If lpu.Value = False And tbState.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer State"
tbState.SetFocus
End If
If lpu.Value = False And tbZip.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer Zip"
tbZip.SetFocus
End If
If lpu.Value = False And tbEmail.Text = "" Then
Cancel = 1
MsgBox "Please Enter Customer Email"
tbEmail.SetFocus
End If
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Customer Database")
Dim lRow As Long
lRow = ws.Cells(1, 1).End(xlDown).Row + 1
ws.Cells(lRow, 1).Value = tbName
ws.Cells(lRow, 2).Value = tbAddress
ws.Cells(lRow, 3).Value = tbCity
ws.Cells(lRow, 4).Value = tbState
ws.Cells(lRow, 5).Value = tbZip
ws.Cells(lRow, 6).Value = tbEmail
tbName.Value = ""
tbAddress.Value = ""
tbCity.Value = ""
tbState.Value = ""
tbZip.Value = ""
tbEmail.Value = ""
lRow = lRow - 1
UserForm2.Hide
UserForm1.Show
End Sub
Last edited by a moderator: