473,385 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Code to update New Password in Place of old password in Employee Table

2
Hello,
I have created a table called EmployeeTable and am done with login page, But problem is, when ever a user try to change password it shows "password change sucessfull" but the new password not been updated(replaced) in place of old password in employee table. so am attaching the code which i have written in VB(Ms access 2003). pls give me a code to update password.. (For Esay understanding I have provided the space where i need to update my codes in program (before Mess box "password change sucessful"))
Expand|Select|Wrap|Line Numbers
  1. Private Sub SaveExit_Click()
  2.  
  3. 'Check to see if data is entered into the Employee ID box
  4.  
  5.     If IsNull(Me.EmployeeID) Or Me.EmployeeID = "" Then
  6.         MsgBox "You must enter a Employee ID.", vbOKOnly, "Required Data"
  7.         Me.EmployeeID.SetFocus
  8.         Exit Sub
  9.     End If
  10.  
  11. 'Check to see if data is entered into the old password box
  12.  
  13.     If IsNull(Me.oldpassword) Or Me.oldpassword = "" Then
  14.         MsgBox "You must enter a Old Password.", vbOKOnly, "Required Data"
  15.         Me.oldpassword.SetFocus
  16.         Exit Sub
  17.     End If
  18.  
  19. 'Check to see if data is entered into the New password box
  20.  
  21.     If IsNull(Me.newpassword) Or Me.newpassword = "" Then
  22.         MsgBox "You must enter a New Password.", vbOKOnly, "Required Data"
  23.         Me.newpassword.SetFocus
  24.         Exit Sub
  25.     End If
  26. 'Check to see if data is entered into the New password box
  27.  
  28.     If IsNull(Me.confirmpassword) Or Me.confirmpassword = "" Then
  29.         MsgBox "Please Confirm Password.", vbOKOnly, "Required Data"
  30.         Me.newpassword.SetFocus
  31.         Exit Sub
  32.     End If
  33. 'check to see the Password in EmployeeTable
  34.  
  35.     If Me.oldpassword.Value = DLookup("Password", "EmployeeTable", "[EmployeeID]=" & Me.EmployeeID.Value) Then
  36.  
  37.         EmployeeID = Me.EmployeeID.Value
  38.  
  39.     Else
  40.         MsgBox "Old Password Not Matched . Please Try Again", vbOKOnly, "Invalid Entry!"
  41.         Me.oldpassword.SetFocus
  42.         Exit Sub
  43.     End If
  44. 'check to see the New Password should match with confirm Password
  45.     If Me.newpassword.Value = Me.confirmpassword.Value Then
  46. 'Replace Password In Employee Table by New passsword
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.         MsgBox "Password Change Sucessfull", vbOKOnly, "Invalid Entry!"
  57. 'Close Change Password  form and open LogIN screen
  58.         DoCmd.Close acForm, "changepassword", acSaveNo
  59.         DoCmd.OpenForm "LogIN"
  60.     Else
  61.         MsgBox "New Password Not Matched . Please Try Again", vbOKOnly, "Invalid Entry!"
  62. End If
  63. End Sub
Jan 11 '12 #1
5 2722
Rabbit
12,516 Expert Mod 8TB
The problem is that you don't actually have any code to change the password, that's why the password stays the same in the table.
Jan 11 '12 #2
Pappu
2
ya that i know, thats why i given space there.. if u have the standard format of code, u post it..........
Jan 11 '12 #3
Mihail
759 512MB
Just this morning I write this code that seems to be what you are looking for. Of course you must operate some adaptations.

_Firme is a table (can be your table with passwords):
It has this fields:
- ID_Firma (Autonumber - Long): can be the ID field in your table
- FirmaName (Text - unique values): can be the field with names in your table
- IsDefault (Yes / No) : can be the field with passwords in your table

Also, in my form I have a combo box bound to this table with two columns: first two fields.
When I select a name from my combo box the value for combo box become equal to record ID

Then I use this code to set the IsDefault field to True for that record and for all other records to False (you can use that to store your new password)


Expand|Select|Wrap|Line Numbers
  1. Dim DB As DAO.Database
  2.     Set DB = CurrentDb()
  3. Dim Rst As DAO.Recordset
  4.     Set Rst = DB.OpenRecordset("_Firme")
  5.     Rst.MoveFirst
  6.     Do While Not Rst.EOF()
  7.         With Rst
  8.             .Edit
  9.             !IsDefault = (CLng(cmbFirma) = Rst!ID_Firma)
  10.             .Update
  11.             .MoveNext
  12.         End With
  13.     Loop
  14.     Rst.Close
  15.     Set Rst = Nothing

Pay attention to .Edit and .Update statements:
If first is ommited an error occur (Believe me !!! :))) ).
If the second one is omitted nothing happen in the table (again Believe me !!! :))) )

Hope this is a help for you.
Good luck !
Jan 11 '12 #4
NeoPa
32,556 Expert Mod 16PB
Please check out When Posting (VBA or SQL) Code, as well as the site guidelines it seems you need to read too.
Jan 11 '12 #5
Rabbit
12,516 Expert Mod 8TB
You don't necessarily have to use the record set based approach that Mihail uses. You can use something as simple as the DoCmd.RunSQL() function to execute an update query.

One related caveat to password storage. I notice you're storing the password as plain text. I just want to say that that is highly insecure and borders on reckless. If you're going to be storing passwords, you really need to store the hash, preferably with a salt. Storing plaintext passwords is how accounts get compromised, and not just the account for the program you have but a lot of people use the same password for everything and it compromises all those accounts too.
Jan 11 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fons Roelandt | last post by:
Heelo, I have to Update all fields from a table with the values of a related table, i've tried some querys i found on the internet, but nothing seems to word, i even tried to lookup the value...
1
by: N. Graves | last post by:
I have a table(Useraccess that has several different columns of data (userid, password, num_of_access etc) I get a different table of user info data every couple of days. The NewTable has only the...
1
by: jlrolin | last post by:
I'm trying to update a new field in a table from a COUNT(*) of Registration IDs grouped by Course IDs. COUNT: Course_ID 11 1234 12 2323 19 8932 ...
1
by: sridhar4554 | last post by:
How to give a grant like select,update,insert on a single table i had tried with the command grant eg:GRANT SELECT,INSERT,UPDATE ON DTS_OUTBOX_QUEUE TO sanpapps@dap1 IDENTIFIED BY 'disable';...
2
by: ssakhamuri | last post by:
hai guys, i want to update the date in a table like i just want to update the year of the of thie date in table for example if rows are like this, 2006-5-14 00:00:00,2005-4-14 00:00:00 then i...
7
by: rekhasc | last post by:
plz help me to write the code to change the current password and to update the new password: i have written the code but its giving error,my code is Private Function pass() As Boolean Dim cn...
1
by: Splattman | last post by:
How do I use VBA Code to update a field in a table in Access? I am trying select case queries and do while loop queries. I don't know how to open the source and then update the field I need to.
1
by: abinesh.agarwal | last post by:
Hi , I want to update the column in a table based on the updation of the other column in the same table, but not getting the desired result. DDL: CREATE TABLE .( NULL,
2
by: Mel | last post by:
Can anyone assist me in how I would structure this code to update every record in a table? I need to loop through each record and increase the cost field by a certain percentage. How do I loop...
1
by: mamabeav54 | last post by:
i have created a record on a linked table from within ms access using a stored procedure in sql server 2005. the insert record proc sends a 0 return code. i can view the record, but when i try to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.