Userform Terminate
A mesbox returs a test string not vbYesNo. the ascii string need to be
compared using the strcomp() function
if strcomp(ua,"YES") then
You also want to convert the response to either lower case or upper case.
better
if strcomp(strconv(ua,vbUpperCase),"YES") = 0 then
"TimT" wrote:
Hey Troops,
I would like to give the user the option to abort a Terminate (clicking the
red X) if they choose.
If there is data that the user input and they accidently terminate I was
trying to give the user the choice to abort the close and run another sub but
the form still closes and then runs the msgbox part of the code.
here's my code, any help would be greatly appreciated!!:
Private Sub UserForm_Terminate()
If (Me.BusName.Value) = "" Then
Unload Me
End If
If (Me.BusName.Value) < "" Then
Dim ua As String
ua = MsgBox("Do you wish to save the current data entered on this
form?", vbYesNo)
If ua = vbYes Then
Exit Sub
Else
If ua = vbNo Then
Unload Me
End If
End If
End If
End Sub
|