Table update problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pbrunson
    New Member
    • Jan 2008
    • 5

    #1

    Table update problem

    For two days I have tried every combination of code I could find / think of. I have a simple update I want to do to a field, but I am getting a data type miss match error when I set the WHERE to a varable.

    Here is what I have;

    Dim MyID As Integer
    MyID = UserName.GetUse rName()
    DoCmd.RunSQL "UPDATE tblEmployees SET [strEmpPassword]='" & Me.txtNewPasswo rd.Value & "' WHERE [lngEmpID] ='" & MyID & "';"

    The function GetUserName() works everywhere else I use it. It returns the record ID number for the user.

    I can replace the MyID in the SQL statement to a number and it works. I have also replaced UserName.GetUse rName() with a number and it breaks the SQL query also. I just do not know where to go from here. Any help would be great.
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Get off the single quotes around MyID.

    Comment

    • pbrunson
      New Member
      • Jan 2008
      • 5

      #3
      Found the answer

      Wow, OK that worked. Thank you. Quick question, is there a way to not have access notify the user that they are "about to update 1 row"?

      ** I found the answer in another post. Thank you again
      Last edited by pbrunson; Jan 2 '08, 07:27 PM. Reason: Found the answer

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        You are welcome.

        Best regards,
        Fish

        Comment

        Working...