Results 1 to 8 of 8
  1. #1
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32

    Cool Update Userstbl

    Whats up people!

    Ok I've been fighting this login script for awhile. Some of you have helped me out a lot and I am extremely grateful. I am close to finishing this thing I can feel it. Here's what I have so far.

    Option Compare Database
    Option Explicit

    Private Sub Update_Click()
    Dim Passwords As String
    Dim DateUpdated As Date
    Dim ExpiredDate As Date
    Dim dbs As DAO.Database
    Dim Users As DAO.Database
    Dim usrLogin As TextBox
    Dim loginID(7) As String
    loginID(1) = "dgrant"
    loginID(2) = "yalvarez"
    loginID(3) = "belbrecht"
    loginID(4) = "dgarcia"
    loginID(5) = "ddepuydt"
    loginID(6) = "jllera"


    loginID(7) = "kabler"

    Set dbs = CurrentDb


    'Check to see if data is entered into the OldPassword text box
    If IsNull(Me.OldPassword.Value) = True Then
    MsgBox "Please enter Old Password", vbInformation, "Old Password Required"
    Me.OldPassword.SetFocus
    Exit Sub
    End If


    If Me.OldPassword.Value = DLookup("Passwords", "Users") Then
    dbs.Execute "Update Users Set (DateUpdated = '" & CStr(Now()) & "', Where loginID() = '" & usrLogin.Text & "'"
    dbs.Execute "Update Users Set (ExpiredDate = '" & CStr(Now()) & "', Where loginID() = '" & usrLogin.Text & "'"
    Exit Sub
    End If

    'Check to see if data is entered into the NewPassword text box
    If IsNull(Me.NewPassword.Value) = True Then
    MsgBox "Please enter New Password", vbInformation, "New Password Required"
    Me.NewPassword.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the ConfirmPassword text box
    If IsNull(Me.ConfirmPassword.Value) = True Then
    MsgBox "Please confirm password", vbInformation, "Confirmation Required"
    Me.ConfirmPassword.SetFocus
    Exit Sub
    End If

    If Me.ConfirmPassword.Value = Me.NewPassword.Value Then
    'Do what you normally do
    Else
    MsgBox "Password does not match", vbCritical, "ERROR"
    End If

    If Len(Me.NewPassword.Value) > 0 Then
    dbs.Execute "Update Users Set(Passwords = '" & Me.NewPassword.Value & "') Where loginID() = '" & usrLogin.Text & "'"
    End If
    End Sub

    The blue is where it is giving me a debug error. I know that the if statement just checks to see if something is written in the text box but I didn't really how else to write it out. Can some please help me with this? thanks guys and gals..

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Try this -
    Code:
    dbs.Execute "Update Users Set [Passwords] = '" &  Me.NewPassword.Value & "' Where [loginID()] = '" & usrLogin.Value  & "'"
    I think there is a missing space between Set and (Passwords.

  3. #3
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32
    still gives a debug error that states "object variable or with block variable not set". Should I declare the usrLogin as string?

  4. #4
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32
    I'm not sure what happened, but now I get no error and it still does not update my table. please advise.

    Option Compare Database
    Option Explicit

    Private Sub Update_Click()
    Dim Passwords As String
    Dim DateUpdated As Date
    Dim ExpiredDate As Date
    Dim dbs As DAO.Database
    Dim Users As DAO.Database
    Dim usrLogin As TextBox
    Dim loginID(7) As String
    loginID(1) = "dgrant"
    loginID(2) = "yalvarez"
    loginID(3) = "belbrecht"
    loginID(4) = "dgarcia"
    loginID(5) = "ddepuydt"
    loginID(6) = "jllera"
    loginID(7) = "kabler"

    Set dbs = CurrentDb

    'Check to see if data is entered into the OldPassword text box
    If IsNull(Me.OldPassword.Value) = True Then
    MsgBox "Please enter Old Password", vbInformation, "Old Password Required"
    Me.OldPassword.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the NewPassword text box
    If IsNull(Me.NewPassword.Value) = True Then
    MsgBox "Please enter New Password", vbInformation, "New Password Required"
    Me.NewPassword.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the ConfirmPassword text box
    If IsNull(Me.ConfirmPassword.Value) = True Then
    MsgBox "Please confirm password", vbInformation, "Confirmation Required"
    Me.ConfirmPassword.SetFocus
    Exit Sub
    End If

    If Me.ConfirmPassword.Value = Me.NewPassword.Value Then
    'Do what you normally do
    Else
    MsgBox "Password does not match", vbCritical, "ERROR"
    End If


    If Me.OldPassword.Value = DLookup("Passwords", "Users") Then
    dbs.Execute "Update Users Set (DateUpdated = '" & CStr(Now()) & "', Where loginID(1,7) = '" & usrLogin.Value & "'"
    dbs.Execute "Update Users Set (ExpiredDate = '" & CStr(Now()) & "', Where loginID(1,7) = '" & usrLogin.Value & "'"
    Exit Sub
    End If

    dbs.Execute "Update Users Set [Passwords] = '" & Me.NewPassword.Value & "' Where [loginID(1,7)] = '" & usrLogin.Value & "'"
    DoCmd.OpenForm "Login", acNormal, , , acFormAdd
    DoCmd.Close acForm, "UpdatePassword"
    Exit Sub
    End Sub

  5. #5
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    dbs.Execute "Update Users Set (DateUpdated = '" & CStr(Now()) & "', Where loginID(1,7) = '" & usrLogin.Value & "'"
    dbs.Execute "Update Users Set (ExpiredDate = '" & CStr(Now()) & "', Where loginID(1,7) = '" & usrLogin.Value & "'"
    loginID(1,7) ?????

  6. #6
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32
    loginID's 1 through 7. at the top of the script I identified the users. did I not do that correctly?

  7. #7
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32
    Well after playing around I finally got it to go through without errors but it still does not update my users table.

    Here it is again:

    Option Compare Database
    Option Explicit

    Private Sub Update_Click()
    Dim Passwords As String
    Dim DateUpdated As Date
    Dim ExpiredDate As Date
    Dim dbs As DAO.Database
    Dim Users As DAO.Database
    Dim usrLogin As TextBox
    Dim loginID(7) As String
    loginID(1) = "dgrant"
    loginID(2) = "yalvarez"
    loginID(3) = "belbrecht"
    loginID(4) = "dgarcia"
    loginID(5) = "ddepuydt"
    loginID(6) = "jllera"
    loginID(7) = "kabler"

    Set dbs = CurrentDb

    'Check to see if data is entered into the OldPassword text box
    If IsNull(Me.OldPassword.Value) = True Then
    MsgBox "Please enter Old Password", vbInformation, "Old Password Required"
    Me.OldPassword.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the NewPassword text box
    If IsNull(Me.NewPassword.Value) = True Then
    MsgBox "Please enter New Password", vbInformation, "New Password Required"
    Me.NewPassword.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the ConfirmPassword text box
    If IsNull(Me.ConfirmPassword.Value) = True Then
    MsgBox "Please confirm password", vbInformation, "Confirmation Required"
    Me.ConfirmPassword.SetFocus
    Exit Sub
    End If

    If Me.ConfirmPassword.Value = Me.NewPassword.Value Then
    'Do what you normally do
    Else
    MsgBox "Password does not match", vbCritical, "ERROR"
    End If


    If Me.OldPassword.Value = DLookup("Passwords", "Users") Then
    dbs.Execute "Update Users Set (DateUpdated = '" & CStr(Now()) & "', Where loginID() = '" & usrLogin.Value & "'"
    dbs.Execute "Update Users Set (ExpiredDate = '" & CStr(Now()) & "', Where loginID() = '" & usrLogin.Value & "'"
    dbs.Execute "Update Users Set (Passwords = '" & Me.NewPassword.Value & "', Where loginID() = '" & usrLogin.Value & "'"
    Exit Sub
    End If

    DoCmd.OpenForm "Login", acNormal, , , acFormAdd
    DoCmd.Close acForm, "UpdatePassword"

    End Sub

    Please let me know where I am going wrong. Thanks guys/gals...

  8. #8
    Jllera is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    32
    Can anyone help me out please?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 11-05-2014, 05:27 PM
  2. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  3. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  4. Replies: 4
    Last Post: 11-10-2011, 03:41 PM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums