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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Dumb Input Box Question....

Status
Not open for further replies.

ChiTownDiva

Technical User
Jan 24, 2001
273
US
The answer is probably in my face and I just can't see it, but here goes:

Private Sub Workbook_Open()
Application.WindowState = xlMaximized

Worksheets("Shamika Bailey").Visible = False
Worksheets("Michael Brown").Visible = False
Worksheets("LaJuanda Hall").Visible = False
Worksheets("Jean Hedden").Visible = False
Worksheets("Adria Lundy").Visible = False
Worksheets("Yasu Talodin").Visible = False
Worksheets("Melissa Thompson").Visible = False
Worksheets("Lovita Whitfield").Visible = False

Dim GetPassword As String
Dim IncorrectResponse As Long
Dim Response As Long

Password: GetPassword = InputBox("Enter Password", "Password")

If GetPassword = "pktspfk" Then
Worksheets("Shamika Bailey").Visible = True
Worksheets("Michael Brown").Visible = False
Worksheets("LaJuanda Hall").Visible = False
Worksheets("Jean Hedden").Visible = False
Worksheets("Adria Lundy").Visible = False
Worksheets("Yasu Talodin").Visible = False
Worksheets("Melissa Thompson").Visible = False
Worksheets("Lovita Whitfield").Visible = False

Else

IncorrectResponse = MsgBox("Incorrect Password", vbRetryCancel + vbCritical)

End If


If Password = 2 Then
Workbooks("Book5.xls").Close SaveChanges:=False
End If

If IncorrectResponse = 4 Then
GoTo Password 'GetPassword

ElseIf IncorrectResponse = 2 Then
Workbooks("Book5.xls").Close SaveChanges:=False

End If
End Sub


Okay, here's the dilema...when I click the cancel button on the "Password" input box, the "Incorrect Password" message box pops up. This is good. When I click "Retry" on the message box, the "Password" input box comes back up. This is also good. When I enter a correct password, the sheet becomes visible, but the "Password" box won't go away. It keeps prompting for a password. This is not good. I know the answer is staring me in the face, but I can't see it.

Does anybody out there see it?

Thanks.

ChiTownDivaus [ponytails2]
 
One more thing...how do I stop that "Disable/Enable" Macros box from popping up everytime I open the worksheet?

My security is set to Medium.

Thanks.
 
ChiTownDiva,

I'm revamping your procedure; will put something together this evening. Gonna get rid of those ugly GoTo's. [evil]


Regards,
Mike
 
 
Here's how I might restructure it:

Private Sub Workbook_Open()
Dim GetPassword As String
dim PassWordOK as boolean
Application.WindowState = xlMaximized
Worksheets("Shamika Bailey").Visible = False
Worksheets("Michael Brown").Visible = False
Worksheets("LaJuanda Hall").Visible = False
Worksheets("Jean Hedden").Visible = False
Worksheets("Adria Lundy").Visible = False
Worksheets("Yasu Talodin").Visible = False
Worksheets("Melissa Thompson").Visible = False
Worksheets("Lovita Whitfield").Visible = False

do
PasswordOK=true
GetPassword = InputBox("Enter Password", "Password")
select case GetPassword
case "pktspfk"
Worksheets("Shamika Bailey").Visible = True
case "kas;fdj"
Worksheets("Michael Brown").Visible = true
...
case else
PasswordOK=false
if GetPassword="" then 'user didn't enter pwd (Cancel)
Workbooks("Book5.xls").Close SaveChanges:=False
End If

if MsgBox("Incorrect Password", vbRetryCancel + vbCritical)=vbcancel then
Workbooks("Book5.xls").Close SaveChanges:=False
End If
end select
loop until PasswordOK
End Sub

Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top