M
Marissa
I have a userform where the user enters some numbers. I want to check that
the number identified as "mininum temp" is lower than the one identified as
"maximum temp". I wrote:
Private Sub CommandButton2_Click()
'next button
ActiveDocument.FormFields("mintemp").Result = mintemp.Value
ActiveDocument.FormFields("maxtemp").Result = maxtemp.Value
ActiveDocument.FormFields("cur").Result = cur.Value
ActiveDocument.FormFields("minpres").Result = minpres.Value
ActiveDocument.FormFields("avgh").Result = avgh.Value
ActiveDocument.FormFields("maxh").Result = maxh.Value
ActiveDocument.FormFields("process").Result = process.Value
ActiveDocument.FormFields("contam").Result = contam.Value
If mintemp.Value = "" Then
MsgBox ("Please enter minimum temperature.")
mintemp.SetFocus
ElseIf maxtemp.Value = "" Then
MsgBox ("Please enter maximum temperature.")
maxtemp.SetFocus
ElseIf cur.Value = "" Then
MsgBox ("Please enter current temperature")
cur.SetFocus
ElseIf avgh.Value = "" Then
MsgBox ("Please enter average humidity.")
avgh.SetFocus
ElseIf maxh.Value = "" Then
MsgBox ("Please enter maximum humidity.")
maxh.SetFocus
ElseIf mintemp.Value > maxtemp.Value Then
MsgBox ("Minimum temperature cannot be greater than
maximum temperature.")
mintemp.SetFocus
Else
ambient.Hide
AirTreatDetail.Show
End If
End Sub
This works the first time, and maybe the second time, but the more times I
go through it the less it works. Sometimes I can only avoid the message box
when both numbers are equal.
What is wrong?
the number identified as "mininum temp" is lower than the one identified as
"maximum temp". I wrote:
Private Sub CommandButton2_Click()
'next button
ActiveDocument.FormFields("mintemp").Result = mintemp.Value
ActiveDocument.FormFields("maxtemp").Result = maxtemp.Value
ActiveDocument.FormFields("cur").Result = cur.Value
ActiveDocument.FormFields("minpres").Result = minpres.Value
ActiveDocument.FormFields("avgh").Result = avgh.Value
ActiveDocument.FormFields("maxh").Result = maxh.Value
ActiveDocument.FormFields("process").Result = process.Value
ActiveDocument.FormFields("contam").Result = contam.Value
If mintemp.Value = "" Then
MsgBox ("Please enter minimum temperature.")
mintemp.SetFocus
ElseIf maxtemp.Value = "" Then
MsgBox ("Please enter maximum temperature.")
maxtemp.SetFocus
ElseIf cur.Value = "" Then
MsgBox ("Please enter current temperature")
cur.SetFocus
ElseIf avgh.Value = "" Then
MsgBox ("Please enter average humidity.")
avgh.SetFocus
ElseIf maxh.Value = "" Then
MsgBox ("Please enter maximum humidity.")
maxh.SetFocus
ElseIf mintemp.Value > maxtemp.Value Then
MsgBox ("Minimum temperature cannot be greater than
maximum temperature.")
mintemp.SetFocus
Else
ambient.Hide
AirTreatDetail.Show
End If
End Sub
This works the first time, and maybe the second time, but the more times I
go through it the less it works. Sometimes I can only avoid the message box
when both numbers are equal.
What is wrong?