Thread: Warning Message
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ewing25 Ewing25 is offline
external usenet poster
 
Posts: 62
Default Warning Message

What im trying to do is make it so when someone doesnt input a value in a
certain field it comes up with a msgbox that tells them to fill it in. Then
when they press Okay on the msgbox it goes back to the form without
submitting it.

So far i have everything except making it so when you click okay on the
message box it goes back to the form without submitting the data or clearing
the form. Also just to make it so the warning message only appears once even
if they dont fill in 2 required fields.

Heres my code:

Private Sub CommandButton1_Click()
Set wks = Worksheets("Trip")

lrA = wks.Cells(Rows.Count, 1).End(xlUp).Row
lrB = wks.Cells(Rows.Count, 2).End(xlUp).Row
lrD = wks.Cells(Rows.Count, 3).End(xlUp).Row
lrE = wks.Cells(Rows.Count, 4).End(xlUp).Row
lrA = wks.Cells(Rows.Count, 5).End(xlUp).Row
lrC = wks.Cells(Rows.Count, 6).End(xlUp).Row

wks.Range("B" & lrA + 1) = ListBox1.Text
wks.Range("F" & lrA + 1) = TextBox1.Text
wks.Range("D" & lrA + 1) = TextBox3.Text
If TextBox3.Text = "" Then
UserForm4.Show
End If

wks.Range("E" & lrA + 1) = TextBox4.Text
If TextBox4.Text = "" Then
UserForm4.Show
End If

wks.Range("A" & lrA + 1) = TextBox5.Text
wks.Range("C" & lrA + 1) = TextBox6.Text
TextBox1.Text = ""
TextBox4.Text = ""
TextBox3.Text = ""
TextBox6.Text = ""

End Sub

Private Sub CommandButton2_Click()
Unload UserForm3
End Sub