Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Protect Forum_Unload

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
0
0
I want a simple Password protectection from elimenating a app from being closed. Reguardless of what I do it still closes the app.


Private Sub Form_Unload(Cancel As Integer)
Dim EX As String

EX = InputBox("Please Enter Administator Password to Exit?", "Q&A")

If EX = "123" Then
Set db = Nothing
db.Close
End
Else
Call setf 'Sets focus to textbox
End If
End Sub
 
Setting cancel to any nonzero value prevents the form from being removed. So, your else clause becomes

Else
Call setf
Cancel = 1
End If
End Sub


Best wishes,
tootired (Jonathan Clarke)



 
And while you're at it, get rid of the end statement as well.

Private Sub Form_Unload(Cancel As Integer)
Dim EX As String

EX = InputBox("Please Enter Administator Password to Exit?", "Q&A")

If EX = "123" Then
Set db = Nothing
db.Close
Else
Call setf
Cancel = 1
End If

End Sub


Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top