LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default UserForm MsgBox problems

I have a userform that requests a password and opens up a specific sheet
depending on the password. My problem is when I enter in an incorrect
password, a MsgBox appears, but it won't go away when I hit Ok. It'll go
through the count and exit the userform. Here's my code:

Private Sub cmdOk_Click()

Dim lCount As Long

'Allow 3 attempts at password
For lCount = 1 To 3
If Me.txtPassword.Value = vbNullString Then 'Cancelled
Unload Me
Exit Sub
End If
Select Case Me.txtPassword.Value
Case "Sheet2"
ActiveWorkbook.Sheets("Sheet2").Visible = True
Unload Me
Exit For
Case "Sheet3"
ActiveWorkbook.Sheets("Sheet3").Visible = True
Unload Me
Exit For
Case Else
Answer = MsgBox("Password incorrect", vbCritical)
End Select
Next lCount

If lCount = 4 Then 'They use up their 3 attempts
ActiveWorkbook.Sheets("Sheet1").Activate
Unload Me
Exit Sub
End If
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MsgBox Replacement w/ an UserForm Chuckles123[_37_] Excel Programming 0 October 10th 04 04:17 PM
MsgBox Replacement w/ an UserForm Chuckles123[_36_] Excel Programming 2 October 10th 04 04:05 PM
MsgBox Replacement w/ an UserForm Chuckles123[_35_] Excel Programming 1 October 10th 04 01:40 PM
MsgBox Replacement w/ an UserForm Chuckles123[_34_] Excel Programming 2 October 9th 04 05:48 PM
MsgBox Replacement w/ an UserForm Chuckles123[_32_] Excel Programming 1 October 9th 04 03:59 PM


All times are GMT +1. The time now is 09:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"