Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 26th, 2007, 07:57 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default using password in Acces

Hi again,

I have another question.

What I would like is to have a form with action buttons (I know how to make them), but when I press one of those buttons, a username and password should be asked before being able to open the next form. I would also like the possibility for the user to change the password if he wants to. What do I have to do to make this work. I guess I have to start making a table with the usernames and a first standard password, but what code should I use to make for acces to check if the password is correct and if the user wants to change the password...

Thanks

Reply With Quote
  #2 (permalink)  
Old January 26th, 2007, 09:05 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

The button event should NOT open the next form.

You should create an intermediate form, and have two text fields on it, one formatted for passwords so only "****" shows up. Make this form POP-UP and MODAL!!!

Then have a Button on that form to submit the username and password to continue.

Put code on THAT button to go to the Username/Password table (you have one of these, right?) and look up the username, and then check the password against it. If it matches, open the following form. If it doesn't match, tell the user and either keep the current form open, or send them back. This intermediate form should also have a cancel button that opens the first form again.

As to changing the password: create another form with 4 text boxes on it. The text boxes are:

txtUsername - user types in their username
txtOldPassword - user types in old password (password format)
txtNewPass1 - user types in new password (password format)
txtNewPass2 - user types in new password again (password format)

Check to make sure each text box has text in it individually, and then take the values of txtNewPass1 and txtNewPass2 and compare them. If they match, proceed, if not, give the proper warnings and restart.

Then take the username, look it up in the Username table, check the password for accuracy, if it is right, substitute the New password with:

rs("Password") = sNewPass1
rs.Update

Do you need more than this?




mmcdonal
Reply With Quote
  #3 (permalink)  
Old January 26th, 2007, 06:35 PM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I believe I need more... I'm still not used to write complex code for these kind of things so... (might be easy for you, but is still complex for me, but doing me best to understand the code)

I already created an intermediate form with the name frmBA01. On this form I have 2 text boxes, one for the username and the second for the password. They are called "username" and "password", makes it easy to remember :). Then at the bottom I have an OK and a Cancel button, called cmdOK and cmd Annuleren. The table were the usernames and password comes from is called "tblusernameandpassword" and has the fields "Username" and "Password". Both of them are text-type.

Could you give me the complete code with this information or not for both asking and changing the passwords...

Thanks already for helping.

Reply With Quote
  #4 (permalink)  
Old January 29th, 2007, 09:47 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Okay, the easiest way for you to do this is to bind the login form to tblusernameandpassword. Then put the username on as a combo box and allow the user to select their name from a list. Put the password field on the form, but hide it. Then put an unbound text box on the form, and on the on click event of the Okay button, put this code:

Dim sPass, sDoc As String

sPass = Me.UboundTextBoxName

If sPass = Me.Password Then
   sDoc = "frmNextFormAfterLoginFormName"
   Else
   MsgBox "Your password is incorrect.", vbCritical
   Exit Sub
End If

DoCmd.OpenForm sDoc, acNormal

On the Cancel button, just have it exit the app. (Application.Quit)

Did that work for you?


mmcdonal
Reply With Quote
  #5 (permalink)  
Old January 29th, 2007, 01:23 PM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just have another question. When I select a username in the combo box, the hidden password field is not updated to the correct password. I tried to make this with a text box and a combo box, but I don't seem to get it updated with the correct password. I guess it can't work with the combo box, because it is hidden and I can't choose the value. How can the value be updated to the correct password instead of keeping the password of the first entry in the table?

Also how do I change the number and letters for the password input into ****?

And how can I use the password change? Following you with the warnings if the new passwords don't match and the restart, but not for changing the old password into the new one... Could you give me some more info on this one too?

Thanks so far for all your help...

Reply With Quote
  #6 (permalink)  
Old January 29th, 2007, 01:46 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Okay, we were working on the login here.

If the form is bound to the table with the usernames and passwords, create a combo box using the wizard to find a record on your form. Make that the username look up combo box. Hide the regular username field as well. Then hide the password field. This code should work then. The combo box will navigate to the record for the user, and then populate the form with the username and password in the hiddent text boxes.

Be sure to turn off all the controls for the form, and then set it to pop up and modal as well.

Did that work?


mmcdonal
Reply With Quote
  #7 (permalink)  
Old January 30th, 2007, 11:40 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, now this works. The only thing left to know is how I can be able to make a password change and how to format the input to password so I don't get for exemple 1234 but ****

Reply With Quote
  #8 (permalink)  
Old January 30th, 2007, 01:14 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Do this in Table design view. Select the Password field, then select the Input mask, and select Password. Then make sure to propogate this design change down to all your forms.



mmcdonal
Reply With Quote
  #9 (permalink)  
Old February 6th, 2007, 08:06 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, back on this topic to be able to change the password. The code is not complete, could you check it and complete where I'm wrong?

Private Sub cmdOK_Click()

Dim spass, sNewPass1 As String
Dim rs As ADODB.Recordset

spass = Me.PasswordInput
sNewPass1 = Me.NewPassword

If IsNull(Me.PasswordInput) Or Me.PasswordInput = "" Then
    MsgBox "Gelieve een wachtwoord in te voeren." & vbCrLf & "Veuillez entrer un mot de passe." _
    , vbCritical, "Onvoldoende gegevens"
    Me.PasswordInput.SetFocus
    Exit Sub
ElseIf spass <> Me.Password Then
    MsgBox "Het ingevoerde wachtwoord is ongeldig." & vbCrLf & "Le mot de passe n'est pas correcte.", _
    vbCritical, "Ongeldige invoer"
    Me.PasswordInput.SetFocus
    Exit Sub
ElseIf IsNull(Me.NewPassword) Or Me.NewPassword = "" Then
    MsgBox "Gelieve een nieuw wachtwoord in te voeren." & vbCrLf & "Veuillez entrer un nouveau mot de passe.", vbExclamation
    Me.NewPassword.SetFocus
    Exit Sub
ElseIf IsNull(Me.NewPasswordConfirm) Or Me.NewPasswordConfirm = "" Then
    MsgBox "Geliev het nieuwe wachtwoord nogmaals in te voeren." & vbCrLf & "Veuillez entrer le nouveau mot de passe une deuxième foi.", vbExclamation
    Me.NewPasswordConfirm.SetFocus
    Exit Sub
ElseIf Me.NewPassword <> Me.NewPasswordConfirm Then
    MsgBox "Het nieuwe wachtwoord is niet 2 maal op dezelfde wijze ingegeven." & vbCrLf & _
    "Le Nouveau mot de passe n'a pas été entré de la même façon 2 fois.", vbExclamation
    Me.NewPassword.SetFocus
    Exit Sub
End If

'open recordset and connection
Set rs = New ADODB.Recordset

'change password

rs.???
rs("Password") = sNewPass1
rs.Update

rs.Close

MsgBox "Het wachtwoord is gewijzigd." & vbCrLf & "Le mot de passe as été changé.", vbInformation

DoCmd.Close acForm, "frmLoginChange"
DoCmd.Maximize

End Sub

The last message box is to tell the user the password had been changed.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Acces Autonumber teddyk ASP.NET 2.0 Basics 7 October 22nd, 2008 09:07 PM
avoid direct acces austinf Javascript 1 June 19th, 2006 06:37 AM
java with Acces database colombo_ar BOOK: Beginning Java 2 3 April 30th, 2005 04:37 AM
Acces Db conversion angel_xpmx SQL Language 1 December 1st, 2004 12:08 PM
sntax error or acces violation shoakat Classic ASP Databases 0 November 9th, 2004 07:07 PM



All times are GMT -4. The time now is 12:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.