Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2002
    Location
    Lisse, the Netherlands.
    Posts
    3

    Question Unanswered: Password update wont work - Module error?

    Hi!

    I've got the following problem. I have a form on which users can change their password. On this form there a submit button with the following code:

    *********************
    Private Sub cmdSubmit_Click()
    Dim UpdatePW As New MyTestClass3

    If Me.filledCheck = False Then
    MsgBox "Please complete all entries before " & _
    "submitting your new password.", vbInformation, _
    "Warning"
    ElseIf txtPassword <> txtConfirm Then
    MsgBox "Password and Confirm Password do not " & _
    "match. Re-enter one or both.", vbInformation, _
    "Warning"
    Else
    UpdatePW.NewPW txtEmpID, txtPassword

    End If

    End Sub
    *********************

    Then there is a module, MyTestClass3. The code is:

    *********************
    Sub NewPW(txtEmpID As String, txtPassword As String)
    Dim cmd1 As Command
    Dim strSQL As String

    'Assign the command reference and connection.
    Set cmd1 = New ADODB.Command
    cmd1.ActiveConnection = CurrentProject.Connection

    'Define the SQL string; notice
    'the insertion of passed arguments.
    strSQL = "UPDATE gebruikers " & _
    "SET gebruikers.password = """ & txtPassword & """ " & _
    "WHERE user_id=" & txtEmpID & ";"
    Debug.Print strSQL

    'Assign the SQL string to the command and run it.
    cmd1.CommandText = strSQL
    cmd1.CommandType = adCmdText
    cmd1.Execute

    'Confirmation message
    MsgBox "Your new password is accepted. " & _
    "Return to Employee Authentication or " & _
    "Exit this form.", vbInformation, _
    "Affirmative"

    End Sub
    *********************

    When I click on the submit button there comes a messagebox which says I didnt specify enough paramters :-S
    I can't seem to figure out what is going wrong...can anyone help with this? I think it has to do with declaring txtEmpID as string, but I am not quite sure.

    I am not really an experienced programmer...so please bare with me.

    Thnx in advance,

    Thijs Kromhout

  2. #2
    Join Date
    Oct 2002
    Location
    Rochester, NY
    Posts
    84

    Re: Password update wont work - Module error?

    Originally posted by TheCurve
    Hi!

    I've got the following problem. I have a form on which users can change their password. On this form there a submit button with the following code:

    *********************
    Private Sub cmdSubmit_Click()
    Dim UpdatePW As New MyTestClass3

    If Me.filledCheck = False Then
    MsgBox "Please complete all entries before " & _
    "submitting your new password.", vbInformation, _
    "Warning"
    ElseIf txtPassword <> txtConfirm Then
    MsgBox "Password and Confirm Password do not " & _
    "match. Re-enter one or both.", vbInformation, _
    "Warning"
    Else
    UpdatePW.NewPW txtEmpID, txtPassword

    End If

    End Sub
    *********************

    Then there is a module, MyTestClass3. The code is:

    *********************
    Sub NewPW(txtEmpID As String, txtPassword As String)
    Dim cmd1 As Command
    Dim strSQL As String

    'Assign the command reference and connection.
    Set cmd1 = New ADODB.Command
    cmd1.ActiveConnection = CurrentProject.Connection

    'Define the SQL string; notice
    'the insertion of passed arguments.
    strSQL = "UPDATE gebruikers " & _
    "SET gebruikers.password = """ & txtPassword & """ " & _
    "WHERE user_id=" & txtEmpID & ";"
    Debug.Print strSQL

    'Assign the SQL string to the command and run it.
    cmd1.CommandText = strSQL
    cmd1.CommandType = adCmdText
    cmd1.Execute

    'Confirmation message
    MsgBox "Your new password is accepted. " & _
    "Return to Employee Authentication or " & _
    "Exit this form.", vbInformation, _
    "Affirmative"

    End Sub
    *********************

    When I click on the submit button there comes a messagebox which says I didnt specify enough paramters :-S
    I can't seem to figure out what is going wrong...can anyone help with this? I think it has to do with declaring txtEmpID as string, but I am not quite sure.

    I am not really an experienced programmer...so please bare with me.

    Thnx in advance,

    Thijs Kromhout
    I would suggest that you place parenthesis around the parameters you're sending to the instance of MyTestClass3.
    Regards,
    Terry

  3. #3
    Join Date
    Feb 2002
    Location
    Lisse, the Netherlands.
    Posts
    3
    If I do that de debugger gives a syntax error pointing to the following line where I put the parenthesis

    ....
    Else
    UpdatePW.NewPW (txtEmpID, txtPassword)
    End If
    .......

    BTW: The value of password in table gebruikers is text and so is user_id.

  4. #4
    Join Date
    Oct 2002
    Location
    Rochester, NY
    Posts
    84
    Originally posted by TheCurve
    If I do that de debugger gives a syntax error pointing to the following line where I put the parenthesis

    ....
    Else
    UpdatePW.NewPW (txtEmpID, txtPassword)
    End If
    .......

    BTW: The value of password in table gebruikers is text and so is user_id.
    If you have a class, why don't you try declaring two private string varibles in that class with module scope. You can then create properties for the class to which you can assign the variable values for password and eployee ID.
    i.e at the begining of the class module ...

    Private mstrEmpID as String
    Private mstrPassword as String

    ...

    Property Let Employee(ByVal strEmpID as String)
    mstrEmpID = strEmpID

    End Property

    Property Let Password(ByVal strPassword as String)
    mstrPassword = strPassword

    End Property


    You will also need to modify the class module subroutine NewPW to use the new Private module strings mstrEmpID and mstrPassword. It won't need any parameters passed to it anymore.

    From within cmdSubmit_Click you can then set the property for the class by using syntax similar to the following:
    UpdatePW.Employee = txtEmpID
    UpdatePW.Password = txtPassword

    Hope this helps
    Regards,
    Terry

  5. #5
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    My way of doing it may be more basic, etc. But for what it is worth I have small form that pops up when requested. It has three text fields for the user to type in old password and new password twice. After verifying old password and comparing new ones, if every thing works fine these lines of code should point you in the right direction.


    Set wrkDefault = DBEngine.Workspaces(0)
    Set usrCurrentUser = wrkDefault.Users(CurrentUser())

    usrCurrentUser.NewPassword strOldPassword, strNewPassword
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  6. #6
    Join Date
    Oct 2002
    Posts
    3

    users can't change their pws

    I've just added a form to an access database to allow users to set their passwords. I'm using the same technique as described by John (usr.NewPassword method). I can only get it to work if the user is in the Admins group. Otherwise, the error message is says the user doesn't have permission...

    I've fiddled with the group permissions till I'm blue in face. I've read over and over that users can always change their own password, but mine can't. Any ideas why my Access 2000 database (under Windows XP) is being contrary on this?

  7. #7
    Join Date
    Oct 2002
    Location
    Rochester, NY
    Posts
    84
    Originally posted by jpshay
    My way of doing it may be more basic, etc. But for what it is worth I have small form that pops up when requested. It has three text fields for the user to type in old password and new password twice. After verifying old password and comparing new ones, if every thing works fine these lines of code should point you in the right direction.


    Set wrkDefault = DBEngine.Workspaces(0)
    Set usrCurrentUser = wrkDefault.Users(CurrentUser())

    usrCurrentUser.NewPassword strOldPassword, strNewPassword
    jpshay,
    I'm not sure that what your suggesting will work. It looks like a value needs to be updated in a table called gebruikers not the user's Access database password.
    Regards,
    Terry

  8. #8
    Join Date
    Oct 2002
    Location
    Rochester, NY
    Posts
    84

    Re: users can't change their pws

    Originally posted by wheckler
    I've just added a form to an access database to allow users to set their passwords. I'm using the same technique as described by John (usr.NewPassword method). I can only get it to work if the user is in the Admins group. Otherwise, the error message is says the user doesn't have permission...

    I've fiddled with the group permissions till I'm blue in face. I've read over and over that users can always change their own password, but mine can't. Any ideas why my Access 2000 database (under Windows XP) is being contrary on this?
    I only have Access 2000, so I don't know what the security specifics are in XP. Here's a geuss though -
    You'll need to look into some spefics on Access security, specifically creating or modifying the system.mdw file to handle users, groups, and their permissions and passwords. Be careful doing this! Always keep a backup copy of the default system.mdw file in a remote and safe location. If you use the Access wizard to create a new file, always document the parameters you have input so you can re-create the file should it become necessary to do so.
    Regards,
    Terry

  9. #9
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    The method I showed you was developed in Access 97 and I have converted it to 2000. Both databases versions work and allow users to change their own password.

    Once Accounts are created then object permissions (tables, forms, etc.)can be assigned in the database. Is the restriction that your non-admin users experience due to the fact that your password form is only available to admin people? OR is the code module restricted.

    Seems to work fine on windows 98 and XP
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  10. #10
    Join Date
    Oct 2002
    Posts
    3
    The problem I was having was just reported as a VB error with the call to usr.newpassword. Since then I ran the Security Wizard and got this error message:

    Error ' An unexpected error occured while changing the owner of the database. This problem can occur if you have 1) previously created the database while logged on as one user, 2) secured it previously using the Security Wizard in any version of Access, and then (3) logged on as a different user to run the Security Wizard this time.' The wizard can't complete successfully.

    These conditions were true, becuase I "inherited" the database and the original owner is probably doesn't have an account on the database anymore.

    So, I backed out all the security as described in faq item 34 and regenerated security with the Security Wizard (faq item 2 i think). Now the original problem is fixed (users can change their passwords), I seem to be able to fully administer the database and I am listed as the owner of everything. I do have more work for other databases that I link to and encryption, but at least I'm moving again! Looking back I think database owner was a source of the trouble. Sometimes I saw <unknown>, sometimes <Engine>, I think getting my name in there by regenerating security was key to solving the problems.

    THANKS, this has been a lesson to me, hope it helps others too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •