By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

Replacing table value with different value in VB

P: 6
Here is the problem. I have made a log in script that prompts you to log in with a username and password as the "splash screen" It is an unbounded forum that checks that the username and password are in the employee table, and that they are together, and if it is, it lets you log on. That works just fine. Then i tried to make a form that you can change your password if you please. It has 4 entrys, the user name, password, and then2 of the "new password" if the username and password match the table, and the two new passwords are identical, then it OKs you to proceed. That is where i am getting stuck. I have the table with three fields - and employee number (auto), the employee name, and the password. i cannot figure out how to get the new password to replace the old password without creating a new entry.

here is my script for the password change form. :)

Option Compare Database

Private Sub Cancel_Click()
On Error GoTo Err_Cancel_Click


DoCmd.Close


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Home Page"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub



Private Sub Change_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.Combo13) Or Me.Combo13 = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Combo13.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.OldPass) Or Me.OldPass = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.OldPass.SetFocus
Exit Sub
End If

'Check to see if data is entered into the New Password combo box

If IsNull(Me.NewPass) Or Me.NewPass = "" Then
MsgBox "You must enter a New Password.", vbOKOnly, "Required Data"
Me.NewPass.SetFocus
Exit Sub
End If

'Check to see if data is entered into the Confirm Password box

If IsNull(Me.ConfirmPass) Or Me.ConfirmPass = "" Then
MsgBox "You must ReEnter the New Password.", vbOKOnly, "Required Data"
Me.ConfirmPass.SetFocus
Exit Sub
End If



'Confirm Old Password Matchs UserName

If Me.OldPass.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.Combo13.Value) Then

lngMyEmpID = Me.Combo13.Value


Else

MsgBox "Existing Password does not match User Name. Contact Administrator", vbOKOnly, "Security Alert"
Me.OldPass.SetFocus
Exit Sub

End If




'Check value of password in tblEmployees to see if this
'matches value chosen in combo box

If Me.NewPass.Value <> Me.ConfirmPass.Value Then

MsgBox "New Passwords Do Not Match", vbOKOnly, "Security Alert"
Me.NewPass.SetFocus
Exit Sub

End If


'Replace Old Password with New Password

STUCK HERE







'Open Home Page and Close logon form

MsgBox "Password Successfully Changed", vbOKOnly, "Security Alert"

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Home Page"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "ChangePass", acSaveNo


End Sub

:) Here is my script for the login box

Private Sub cboEmployee_AfterUpdate()

'After selecting user name set focus to password field

Me.txtPassword.SetFocus

End Sub


Private Sub Command6_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblEmployees to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "SplashScreen"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus


End If







'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
Private Sub Command16_Click()
On Error GoTo Err_Command16_Click


DoCmd.Close

Application.Quit

Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub
Private Sub ChngPass_Click()
On Error GoTo Err_ChngPass_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ChangePass"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ChngPass_Click:
Exit Sub

Err_ChngPass_Click:
MsgBox Err.Description
Resume Exit_ChngPass_Click

End Sub


:)

The login box works fine.

the three tables are :

IngEmpID === Employee Auto Number
strEmpName ==== Employee Name
strEmpPassword === Employee Password

any help would be awesome, i have been stuck all day

thanks alot,

Bill
Jul 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: 6
to make it a little more clear, im looking for some type of script that will tell it to replace (strEmpPassword) (which is an entry in a table record) - the one for the username which was entered above - with (ConfirmPass) - the new password which was entered on the form and as of yet has not been stored in a table.

I have tried the replace() function, that just changed letters in a script.


Thanks again
Jul 28 '06 #2

Post your reply

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