View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John Green[_5_] John Green[_5_] is offline
external usenet poster
 
Posts: 1
Default If statements

The following code will display the message when the calendar is clicked if
any of the textboxes are empty.

Change the Or to And if the message is to display only when all the
textboxes are empty.

Private Sub Calendar1_Click()
If TextBox1.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Then
MsgBox "Wrong, wrong, wrong!"
End If
End Sub

The same code can be used in the click event of the command button.

John Green
Sydney

"timmulla" wrote in message
...
Can anyone help me with IF statements in VB code. I have a form with the
following objects:

Calendar1 - CalendarControl
Commandbutton1
TextBox1
TextBox6
TextBox7

I'm trying to have an error message (or userform) pop up if a user clicks
either the calendar1 or the commandbutton1 without having manual inputs in
TextBox1, TextBox6, or TextBox7.

Can anyone help me with this?

Thanks
--

Regards,

timmulla