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: 2
Default Visible property for worksheets objects

Hi. I have a problem I'm needing some help to solve it.

My project is something like this:

In my first worksheet (that I called Login) I have some protected data
which is used by a userform for a login. It contais a column with a
ID, another with his name, another for his password and finally one
for his Department ID.
After this "Login" worksheet I have a few others which name is the
DeparmentID.

Im my "frmLogin" userform I have one combobox (cboNumMec), one textbox
(txtPassword) and three Commandbuttons (OK, Cancel, Change password).
For my combobox I set as rowsource D2:G200 (containing ID, Name,
Password, DepartmentID) and as ColumnWidths 40 pt;110 pt;0 pt;0 pt
(hiding password and department).
Assigned to OK button I have this code:

----------------------------------------------------------------------------------------------------------------------------
Private Sub btnOK_Click()
On Error GoTo Err_btnOK_Click

Dim strNumServiço, strNumMec, strPassword, strPasswordInserida As
String
Dim booPasswordInseridaCheck, booNumMecCheck As Boolean

strNumMec = Me.cboNumMec.Value
strPassword = Me.cboNumMec.Column(2)
strNumServiço = Me.cboNumMec.Column(3)
strPasswordInserida = Me.txtPassword.Value

booNumMecCheck = IsNull(strNumMec)
booPasswordInseridaCheck = IsNull(strPasswordInserida)

If booNumMecCheck = True And booPasswordInseridaCheck = False Then
MsgBox "Falta o número de utilizador.", vbInformation, "Dados em
falta"
Me.cboNumMec.SetFocus
Exit Sub
ElseIf booPasswordInseridaCheck = True And booNumMecCheck = False Then
MsgBox "Falta a palvra-passe.", vbInformation, "Dados em falta"
Me.txtPassword.SetFocus
Exit Sub
ElseIf booNumMecCheck = True And booPasswordInseridaCheck = True Then
MsgBox "Falta o número de utilizador e a palavra-passe.",
vbInformation, "Dados em falta"
Me.cboNumMec.SetFocus
Exit Sub
End If

If strPassword = strPasswordInserida Then
Worksheets(strNumServiço).Visible = True
Application.GoTo Reference:=Worksheets(strNumServiço).Range("A1")
Sheets(1).Visible = False
Me.Hide
Else
MsgBox "Palavra-passe incorrecta. Tente novamente", vbInformation,
"Login"
Me.txtPassword.SetFocus
Exit Sub
End If

Exit_btnOK_Click:
Exit Sub

Err_btnOK_Click:
Select Case Err.Number
Case 9
MsgBox "O código de serviço introduzido não consta deste
documento. Seleccione um dos disponíveis.", vbInformation, "Serviço
não encontrado"
Case 381
MsgBox "Para poder alterar a palavra-passe, insira o nome
de utilizador.", vbInformation, "Alteração da palavra-passe"
Case Else
MsgBox Err.Description
Resume Exit_btnOK_Click
End Select

End Sub
---------------------------------------------------------------------------------------------------------------


When I run my project I get a «Run-time error '9' Subscript ou of
range» when it gets he
Worksheets(strNumServiço).Visible = True

I don't know why I can't use a string to store worksheet name. How can
I solve this?
 
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
Objects with .type property atpgroups Excel Programming 0 August 2nd 06 12:00 PM
VBA visible property miek Excel Programming 1 November 24th 05 04:47 AM
Visible property on Worksheets Russell Lucas Excel Programming 5 February 5th 04 03:26 PM
.Visible Property Jollynicechap Excel Programming 1 July 8th 03 09:06 PM


All times are GMT +1. The time now is 12:17 AM.

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

About Us

"It's about Microsoft Excel"