View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy[_7_] Doug Glancy[_7_] is offline
external usenet poster
 
Posts: 55
Default Having issues with .SetFocus after msgbox...

You don't say which message is displayed twice and which textbox you expect
to get the focus, but here's some comments:

If TextBox2.Value TextBox1.Value
is the same as
If TextBox1.Value < TextBox2.Value

I assume you meant to test if one was either greater than or less than the
other. If that's so why not just test if they are not equal:
If TextBox1.Value < TextBox2.Value

Also, I think you want to turn all of your code into one If, Else, Endif
statement, like this:

If TextBox1.Value = "" Then
....
ElseIf TextBox2.Value = "" Then
....
ElseIf TextBox1.Value < TextBox2.Value
....
EndIf

hth,

Doug

wrote in message
oups.com...
Hello fellow programmers!

If TextBox1.Value = "" Then
MsgBox "You have not confirmed the Information." & vbNewLine & "Please
type the Information in both boxes.", , " - Information Error - "
With TextBox1
.SetFocus
End With
Exit Sub
End If

If TextBox2.Value = "" Then
MsgBox "You have not confirmed the Information." & vbNewLine & "Please
type the Information in both boxes.", , " - Information Error - "
With TextBox2
.SetFocus
End With
Exit Sub
End If

If TextBox2.Value TextBox1.Value Then
MsgBox "The Informations you have entered do not match. Please try
again.", , " - Information Error - "
With TextBox1
.SetFocus
End With
Exit Sub
End If

If TextBox1.Value < TextBox2.Value Then
MsgBox "The Informations you have entered do not match. Please try
again.", , " - Information Error - "
With TextBox2
.SetFocus
End With
Exit Sub
End If

The message box displays twice and the SetFocus doesn't work...any
ideas? Your help is much appreciated!