Change password in form (1 Viewer)

kevinr1

Registered User.
Local time
Today, 12:53
Joined
Jun 17, 2011
Messages
15
Hello all,

I do not understand much of VBA. But I will give my best shot to understand it.
Here is my little problem::

I have login screen. Works fine.
Now I have created a 'change password' form.

Form name: Wachtwoord wijzigen
Old password = txtOld
New password = newpassword1
Verirfy= newpassword2

It has to get all the data from this table:
Tablename: Medewerkers
Field1: Gebruiker
Field2: Wachtwoord


Here is my code:
Code:
Dim sMsg As String     Dim iResponse As Integer       If Len(Nz(Me.txtOld, "")) = 0 Then         MsgBox "Please input the current password.", , "Current Password"         Me.txtOld.SetFocus     ElseIf Len(Nz(Me.newpassword1, "")) = 0 Then         MsgBox "Please enter the new password.", , "New Password"         Me.newpassword1.SetFocus     ElseIf Len(Nz(Me.newpassword1, "")) = 0 Then         MsgBox "Please reenter the new password.", , "New Password Verification"         Me.newpassword2.SetFocus       Else         sMsg = "Are you sure you want to change the password?"         iResponse = MsgBox(sMsg, vbYesNo + vbQuestion + vbDefaultButton1, "Change Password")         Select Case iResponse           Case vbYes             iResponse = acDataErrContinue             If Me.txtOld = Forms!Gebruiker!Wachtwoord Then                 If Me.newpassword1 = Me.newpassword2 Then                     Forms!Medewerkers!Wachtwoord = Me.newpassword1                     MsgBox "The password has been changed to " & Chr(34) & Me.newpassword1 & Chr(34) & ".", , "Password Changed"                     DoCmd.Close acForm, "frmChangePassword"                     DoCmd.Close                 Else                     MsgBox "The new password has been entered incorrectly.", , "New Password"                     Me.newpassword1 = Null                     Me.newpassword2 = Null                     Me.newpassword1.SetFocus                 End If             Else                 MsgBox "The current password is not correct.", , "Incorrect Password"                 Me.txtOld = Null                 Me.txtOld.SetFocus             End If         Case vbNo                 iResponse = acDataErrContinue         End Select     End If   End Sub
I get a message after I press the 'Change password" buttoN:
RunTime error 2450
Start-Up cannot find the reference from "Gebruiker".

I am probally doing something wrong?
 

BobMcClellan

Giving Up Is Unacceptable
Local time
Today, 15:53
Joined
Aug 1, 2009
Messages
104
It looks like....
if it's telling you that ... cannot find the reference from "Gebruiker".
and you are using...
If Me.txtOld = Forms!Gebruiker!Wachtwoord
Try.... Forms!Gebruiker.form.Wachtwoord
hth,
..bob
 

kevinr1

Registered User.
Local time
Today, 12:53
Joined
Jun 17, 2011
Messages
15
No also not working.
I now have this code:
If Me.txtOld = Forms!Gebruiker.Form.Wachtwoord! Then

Giving error: Cannot find FORM Gebruiker...
But it has to get the information from

Table medewerkers.
ield Wachtwoord



The code must be something like this:
If Me.txtOld = Table Medewerkers Field Wachtwoord Then:
blabla


Else.
Xxx
 

BobMcClellan

Giving Up Is Unacceptable
Local time
Today, 15:53
Joined
Aug 1, 2009
Messages
104
No also not working.
I now have this code:
If Me.txtOld = Forms!Gebruiker.Form.Wachtwoord! Then

Giving error: Cannot find FORM Gebruiker...
But it has to get the information from

Table medewerkers.
ield Wachtwoord

The code must be something like this:
If Me.txtOld = Table Medewerkers Field Wachtwoord Then:
blabla


Else.
Xxx
sorry Kevin,
Your description of your problem is all over the place.
Having a hard time trying to figure out what you are trying to do.
you can't say... Me.txtOld = Table Medewerkers Field Wachtwoord.
you can open a recordset with a where clause that points at one row in your
table and check the value of Wachtwoord.
But from your description, it's hard to tell exactly what you are trying to do.
 

kevinr1

Registered User.
Local time
Today, 12:53
Joined
Jun 17, 2011
Messages
15
Yes indeed, I am vague at explaning because i'm 'dutch'... And don't have a lot of knowledge in english explanation... Excuse moi
Here is my database... ( Attachment )

Ignore the 'Menu_Medewerker, the only thing that will work for you guys is: "Wachtwoord wijzigen" button :p


First form that appear for users is login. Try to login with:
asdf1
asdf1
 

Attachments

  • Test for access center help.zip
    36.8 KB · Views: 202

BobMcClellan

Giving Up Is Unacceptable
Local time
Today, 15:53
Joined
Aug 1, 2009
Messages
104
Yes indeed, I am vague at explaning because i'm 'dutch'... And don't have a lot of knowledge in english explanation... Excuse moi
Here is my database... ( Attachment )

Ignore the 'Menu_Medewerker, the only thing that will work for you guys is: "Wachtwoord wijzigen" button :p


First form that appear for users is login. Try to login with:
asdf1
asdf1
Kevin,
I tried to open it but it came up as unrecognized database format. IF you saved it in 2010 can you save it as a 2007 and resend.
thanks.
..bob
 

kevinr1

Registered User.
Local time
Today, 12:53
Joined
Jun 17, 2011
Messages
15
Nvm. It works.
Here is the final code:

Code:
Private Sub Knop19_Click()
Dim sMsg As String, sOldWW As String, strSQL As String
Dim iResponse As Integer
 
    If Len(Nz(Me.txtOld, "")) = 0 Then
        MsgBox "Voer het huidige wachtwoord in.", , "Huidig wachtwoord"
        Me.txtOld.SetFocus
    ElseIf Len(Nz(Me.newpassword1, "")) = 0 Then
        MsgBox "Voer het nieuwe wachtwoord in.", , "Nieuw wachtwoord"
        Me.newpassword1.SetFocus
    ElseIf Len(Nz(Me.newpassword1, "")) = 0 Then
        MsgBox "Voer verificatie wachtwoord in.", , "Verificatie wachtwoord"
        Me.newpassword2.SetFocus
 
    Else
        sMsg = "Weet je zeker dat u het wachtwoord wilt wijzigen?"
        iResponse = MsgBox(sMsg, vbYesNo + vbQuestion + vbDefaultButton1, "Bevestiging!")
        Select Case iResponse
            Case vbYes
                iResponse = acDataErrContinue
                sOldWW = DLookup("Wachtwoord", "Medewerkers", "[Gebruiker]= '" & Me.cboGebruiker & "'")
                If Me.txtOld = sOldWW Then
                    If Me.newpassword1 = Me.newpassword2 Then
                        strSQL = "UPDATE Medewerkers SET Wachtwoord = '" & Me.newpassword1 & "' WHERE [Gebruiker]='" & Me.cboGebruiker & "'"
                        DoCmd.RunSQL strSQL
                        MsgBox "Het wachtwoord is gewijzigd naar: " & Chr(34) & Me.newpassword1 & Chr(34) & ".", , "Wachtwoord gewijzigd!"
                        DoCmd.Close acForm, "Wachtwoord Wijzigen"
                        DoCmd.OpenForm "Menu_Medewerker", , , , , , ""
                    Else
                        MsgBox "Het nieuwe wachtwoord is onjuist ingevoerd.", , "Nieuw Password"
                        Me.newpassword1 = Null
                        Me.newpassword2 = Null
                        Me.newpassword1.SetFocus
                    End If
                Else
                    MsgBox "Het huidige wachtwoord is onjuist.", , "Onjuist wachtwoord"
                    Me.txtOld = Null
                    Me.txtOld.SetFocus
                End If
            Case vbNo
                iResponse = acDataErrContinue
            End Select
    End If


''If Me.txtOud.Value = DLookup("Wachtwoord", "Klachten", "[Gebruiker]= """ & txtName & """") Then
''    If (Me.newpassword1 <> Me.newpassword2) Then
''        messagebox "Wachtwoorden niet gelijk."
''        Exit Sub
''    Else
''        CurrentDb.Execute "UPDATE tablename set password = yourpasswordvalue where employee = your employee"
''        MsgBox ("Congratulations, your password has now been updated")
''        DoCmd.Close
''    End If
''Else
''    MsgBox ("Password Incorrect, please enter the correct password")
''End If
''
''
End Sub
Credits to"OctaFish" from helpmij.nl



//Solved / Thread close
 

Users who are viewing this thread

Top Bottom