Log in

View Full Version : Solved: verifying password in txtbox



Ger
08-19-2011, 04:58 AM
Hello,

i've a problem with a code for verifying a password.

In the textbox i've

Private Sub CommandButton1_Click()
If password.pword.Value = "cosy" Then
pword.Value = ""
password.Hide
Else
MsgBox "verkeerd wachtwoord"
pword.Value = ""
End
End If
End Sub


the macro is:


Sub Start()
If Rows("205:312").Hidden = True Then
openen
Else
Verwerken
End If
End Sub
Sub Verwerken()
ActiveSheet.Unprotect "zima"
Application.ScreenUpdating = False
Dim Cell As Range
For Each Cell In Range("I5:GH84")
If UCase(Cell.Value) = "RES" _
And IsNumeric(Cell.Offset(200).Value) _
And Not Cell.Offset(200).Value = vbNullString Then
'do nothing
Else
Cell.Value = Cell.Offset(200).Value
End If
Next
doen
Sheets("wk 27 tm 52").Select
Application.ScreenUpdating = True
Rows("205:312").Hidden = True
ActiveSheet.Protect password:="zima", DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True

End Sub
Sub openen()
Worksheets("wk 27 tm 52").Activate
password.Show
' If password.pword.Value = "cosy" Then
ActiveSheet.Unprotect "zima"
Rows("205:312").Hidden = False
' password.Hide
ActiveSheet.Protect password:="zima"
' End If
End Sub


if a user stops the textbox (clicking x in the right upper corner) the macro start anyway.
how can i prevent this?

Thx,

Ger

Bob Phillips
08-19-2011, 05:17 AM
Add this to the form



Private Sub UserForm_QueryClose(cancel As Integer, closemode As Integer)

If closemode = vbFormControlMenu Then

MsgBox "Use the Exit button to quit"
cancel = True
End If
End Sub

Ger
08-19-2011, 05:29 AM
XLD,

Thx a lot.

Ger