Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default passwords - userforms - remembering password has been entered

[Excel 2003]

I have a spreadsheet which uses forms to enter and display data. The
Spreadsheet uses a main page form "frmDashboard" from which other userforms
are activated using command buttons. The form frmDashoboard remains open in
the background as a desktop while the user activates the other forms.

I am looking at various methods to password protect the opening of other
forms from the main useform frmDashboard and I use the following code to do
this:

Private Sub CommandButton1_Click()

Dim i_pwd As String
i_pwd = InputBox("Please Enter Password" & vbCrLf & "to activate form")
If i_pwd = "password" Then
UserForm2.Show
Exit Sub
Else
MsgBox "Incorrect password; no action taken.", vbInformation
End If
End Sub

This works well enough however my problem is that the password has to be
entered everytime the command button is pressed (when userform2 is closed).

Is there a way to alter the code so that it remembers that the password has
been entered once? That way it wont keep asking for it.

I would need the algorithm to reset each time the spreadsheet opens, but I
guess it would be okay as long as it remembers it as long as frmDashboard is
open.

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default passwords - userforms - remembering password has been entered

Roger,
Not tested but an approach like following may do what you want. By placing
variable outside procedure, it should hold it's value so long as main form
stays open.

Also, as you are using an inputbox, your password characters are not
marsked. You could consider using another UserForm with textbox char property
set to "*" or have a look at this site which provides a solution to masking
inputbox characters.

http://www.xcelfiles.com/API_09.html

Hope helpful

Dim pwrd As String
Private Sub CommandButton1_Click()

If pwrd = "" Then

pwrd = InputBox("Please Enter Password" & vbCrLf & "to activate form")

If pwrd < i_pwd Then

MsgBox "Incorrect password; no action taken.", vbInformation

pwrd = ""

Exit Sub

End If

End If

If pwrd = i_pwd Then UserForm2.Show

End Sub



--
jb


"Roger on Excel" wrote:

[Excel 2003]

I have a spreadsheet which uses forms to enter and display data. The
Spreadsheet uses a main page form "frmDashboard" from which other userforms
are activated using command buttons. The form frmDashoboard remains open in
the background as a desktop while the user activates the other forms.

I am looking at various methods to password protect the opening of other
forms from the main useform frmDashboard and I use the following code to do
this:

Private Sub CommandButton1_Click()

Dim i_pwd As String
i_pwd = InputBox("Please Enter Password" & vbCrLf & "to activate form")
If i_pwd = "password" Then
UserForm2.Show
Exit Sub
Else
MsgBox "Incorrect password; no action taken.", vbInformation
End If
End Sub

This works well enough however my problem is that the password has to be
entered everytime the command button is pressed (when userform2 is closed).

Is there a way to alter the code so that it remembers that the password has
been entered once? That way it wont keep asking for it.

I would need the algorithm to reset each time the spreadsheet opens, but I
guess it would be okay as long as it remembers it as long as frmDashboard is
open.

Can anyone help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default passwords - userforms - remembering password has been entered

sorry,
missed a line of code when i pasted

Const i_pwd As String = "password"
Dim pwrd As String
Private Sub CommandButton1_Click()

If pwrd = "" Then

pwrd = InputBox("Please Enter Password" & vbCrLf & "to activate form")

If pwrd < i_pwd Then

MsgBox "Incorrect password; no action taken.", vbInformation

pwrd = ""

Exit Sub

End If

End If

If pwrd = i_pwd Then UserForm2.Show

End Sub
--
jb


"Roger on Excel" wrote:

[Excel 2003]

I have a spreadsheet which uses forms to enter and display data. The
Spreadsheet uses a main page form "frmDashboard" from which other userforms
are activated using command buttons. The form frmDashoboard remains open in
the background as a desktop while the user activates the other forms.

I am looking at various methods to password protect the opening of other
forms from the main useform frmDashboard and I use the following code to do
this:

Private Sub CommandButton1_Click()

Dim i_pwd As String
i_pwd = InputBox("Please Enter Password" & vbCrLf & "to activate form")
If i_pwd = "password" Then
UserForm2.Show
Exit Sub
Else
MsgBox "Incorrect password; no action taken.", vbInformation
End If
End Sub

This works well enough however my problem is that the password has to be
entered everytime the command button is pressed (when userform2 is closed).

Is there a way to alter the code so that it remembers that the password has
been entered once? That way it wont keep asking for it.

I would need the algorithm to reset each time the spreadsheet opens, but I
guess it would be okay as long as it remembers it as long as frmDashboard is
open.

Can anyone help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default passwords - userforms - remembering password has been entered

Thanks John,

This works very nicely for my needs

All the best, Roger

"john" wrote:

sorry,
missed a line of code when i pasted

Const i_pwd As String = "password"
Dim pwrd As String
Private Sub CommandButton1_Click()

If pwrd = "" Then

pwrd = InputBox("Please Enter Password" & vbCrLf & "to activate form")

If pwrd < i_pwd Then

MsgBox "Incorrect password; no action taken.", vbInformation

pwrd = ""

Exit Sub

End If

End If

If pwrd = i_pwd Then UserForm2.Show

End Sub
--
jb


"Roger on Excel" wrote:

[Excel 2003]

I have a spreadsheet which uses forms to enter and display data. The
Spreadsheet uses a main page form "frmDashboard" from which other userforms
are activated using command buttons. The form frmDashoboard remains open in
the background as a desktop while the user activates the other forms.

I am looking at various methods to password protect the opening of other
forms from the main useform frmDashboard and I use the following code to do
this:

Private Sub CommandButton1_Click()

Dim i_pwd As String
i_pwd = InputBox("Please Enter Password" & vbCrLf & "to activate form")
If i_pwd = "password" Then
UserForm2.Show
Exit Sub
Else
MsgBox "Incorrect password; no action taken.", vbInformation
End If
End Sub

This works well enough however my problem is that the password has to be
entered everytime the command button is pressed (when userform2 is closed).

Is there a way to alter the code so that it remembers that the password has
been entered once? That way it wont keep asking for it.

I would need the algorithm to reset each time the spreadsheet opens, but I
guess it would be okay as long as it remembers it as long as frmDashboard is
open.

Can anyone help?

Reply
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
Userforms, selection based on sheet and password christinac Excel Programming 1 July 24th 07 08:12 PM
change the characters entered in cell as a Password charactes Tom Ogilvy Excel Programming 0 December 7th 05 01:55 PM
How to delete spreadsheet if wrong password entered? Mike[_104_] Excel Programming 0 November 1st 05 09:26 PM
Multiple Passwords and Maste Password Lucas Excel Discussion (Misc queries) 1 April 2nd 05 10:24 PM
Login and password automatically entered in a web query Jo Eggleton Excel Programming 0 January 26th 05 06:24 PM


All times are GMT +1. The time now is 11:03 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"