Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106

    Unanswered: Update an access table through a form

    Hi

    I am trying to update the user table while changing a password. The code is goes like this:

    strSql = "UPDATE Users SET Users.[Password] = 'UCase(txtPwNew)' ," _
    & " Users.Password_Chg_Date = date " _
    & " WHERE (((Users.Password) = 'UCase (txtPwNew)') " _
    & " AND ((Users.User_name) = 'txtUserName'));"

    Set db = CurrentDb
    db.Execute strSql

    But I am getting an error that says

    "Too few parameters. expected 1."

    Please help

    Also, does the date function returns the current date?

    Thanks
    Mo

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    if the user table is in the database why not use
    docmd.runsql = "sql statment"
    that will run the sql statment that you put in your post and update the table.
    Let us know
    Jim

  3. #3
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106

    Talking

    Hi,

    This ran ok until it hit this part of the statement (Users.Password_Chg_Date = date). I would like to say update the field to today's date. It is not recognizing "Date". What do you think I should use.

    Thanks a lot.
    Mo

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by mkasem
    Hi,

    This ran ok until it hit this part of the statement (Users.Password_Chg_Date = date). I would like to say update the field to today's date. It is not recognizing "Date". What do you think I should use.

    Thanks a lot.
    put in Users.Password_Chg_Date = date()
    see what that does for you
    Jim

  5. #5
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106
    Originally posted by JDionne
    put in Users.Password_Chg_Date = date()
    see what that does for you
    Jim

    It ran ok, but it I got a message that says "your about to update 0 records" and it did not update the table.

    Any idea?

    Thanks
    Mo

  6. #6
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by mkasem
    It ran ok, but it I got a message that says "your about to update 0 records" and it did not update the table.

    Any idea?

    Thanks
    its in your where clause
    you are trying to update the password where the password = Newpassword, be because the update hasnt happend that clause will neaver evaluate as true. take that part out of your where clause and it will work.
    Jim

  7. #7
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106
    Originally posted by JDionne
    its in your where clause
    you are trying to update the password where the password = Newpassword, be because the update hasnt happend that clause will neaver evaluate as true. take that part out of your where clause and it will work.
    Jim
    I know what you are saying Jim, I changed that and still had the same results. I agree with you though, I am still debugging.

    I will let you know if I get a successful run.
    Mo

  8. #8
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Try seperating it into two update statments to try and find where the statemnt is breaking down
    Jim

  9. #9
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106
    Originally posted by JDionne
    Try seperating it into two update statments to try and find where the statemnt is breaking down
    Jim
    I had to make the where clause like this in order to work:
    (WHERE user_Name = '" + lUserName + "' and password = '" + lPassword + "').

    Thanks for your help
    Mo

Posting Permissions

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