PC Review


Reply
Thread Tools Rate Thread

Change UserName & Password from Worksheet,

 
 
Shazi
Guest
Posts: n/a
 
      10th Jun 2008

Hi,

I am developing a vba program for store inventory, it has many sheets
and userforms.

on opening of the workbook one userform is displaying and asking for
the User Name and Password, if it is ok then OK button opens all the
very hidden worksheets.

Textbox1 = Shahzad (username)
Textbox2 = Hilton (password)

My procedure is given below in the UserForm:

My problem is this when ever I want to change the UserName and
Password, i have to open VBA Editor, and open userform for Login, then
I can change the username and password. Instead of doing all this
things, I want to give access to the User to change his username and
password himself.

So, I want to do this from worksheet, here I want to tell you when my
user close the workbook, all sheets are gone very hidden, only Welcome
sheet remaining.

I arrange an other sheet to change the user neme and password.

Sheet name = ChangeUser
B5 = Shahzad (user name)
B6 = Hilton (password)

Now If I change the cell B5 and B6 then it will make the changes
into UserLogin Form. which is given below.

If it is possible then pls send me the solution, I will he thankful to
you.

Best Regards.


Shahzad


My User Log in Function is given below.
------------------------------------------------------

Public cntr As Integer

Private Sub CommandButton2_Click()
' Call sub to validate the password entry
ValidatePWD
End Sub

Private Sub CommandButton4_Click()
UserLogin.Hide
Admin.Show
End Sub

Private Sub UserForm_Activate()
' Set the counter to 0 when the userform activates
cntr = 0
' Set the password character for textbox22 to an asterisk
TextBox2.PasswordChar = "*"
' Set the caption for the CommandButton
CommandButton2.Caption = "Open"
End Sub

Private Sub ValidatePWD()
' Sub to validate the username and password entry.
' If both match, then hide the userform and call

If TextBox1.Value = "shahzad" And _
TextBox2.Value = "hilton" Then

'jobs on opening time

UserLogin.Hide

Application.ScreenUpdating = False

Worksheets("DailyPurchase").Visible = True
Worksheets("DailyIssue").Visible = True
Worksheets("MonthlyPurchase").Visible = True
Worksheets("MonthlyIssue").Visible = True
Worksheets("Category").Visible = True
Worksheets("Employee").Visible = True
Worksheets("Lists").Visible = True
Worksheets("InventoryReport").Visible = True
Worksheets("ReportIssue").Visible = True
Worksheets("ReportPur").Visible = True
Worksheets("Blank").Visible = True
Worksheets("InventoryReport Backup").Visible = True
Worksheets("About").Visible = True
Worksheets("Sheet1").Visible = True
Worksheets("Admin").Visible = xlVeryHidden

Application.ScreenUpdating = True

Sheets("About").Select
Range("A1").Select

MainMenu.Show

Else
' Increment the counter by one
cntr = cntr + 1
' Check to see if the user has unsuccessfuly
' entered an incorrect username or password
' more than three times. If so, display a
' message box and close the workbook.
If cntr > 3 Then
MsgBox "Sorry...invaled password...goodbye"
' for normal excel
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.DisplayFullScreen = False
' Application.CommandBars("Full Screen").Visible = False
Windows(ThisWorkbook.Name).Visible = True

'close file without asking yes/no question.

ThisWorkbook.Close False

Unload Me

Else
' Warn user that username and/or password is incorrect
MsgBox " Attempt #" & cntr & vbCrLf & _
"Incorrect UserName and/or Password entered"
End If
End If
End Sub

Private Sub CommandButton5_Click()
Call UserForm_Initialize
End Sub
Private Sub CommandButton3_Click()

' for normal excel
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.DisplayFullScreen = False
' Application.CommandBars("Full Screen").Visible = False
Windows(ThisWorkbook.Name).Visible = True

' close file without asking yes/no question.

ThisWorkbook.Close False
Unload Me

End Sub

Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub UserForm_Initialize()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox1.SetFocus
End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
' Disable the "X" on the userform so that the user can't

If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox Prompt:=" Sorry but I can't let you do that. "
End If
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot change my server o.0 (username and password help) Frustrated :( Windows Vista Mail 1 2nd Sep 2008 02:47 AM
Stored Username & Password wiped out after password change Sandie Windows XP Security 0 10th Jan 2008 05:47 PM
Change username/password after site moved to new server =?Utf-8?B?a2phNTYyMA==?= Microsoft Frontpage 1 27th Oct 2007 08:34 PM
how do I change setting that requires username/password for new d. =?Utf-8?B?TGF3VGVjaA==?= Microsoft Access Security 3 4th Jan 2005 06:37 PM
Change Username/Password for an existing Windows Service Scott Lezberg \(Deltek\) Microsoft VB .NET 1 28th Nov 2004 10:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 AM.