Connecting Tech Pros Worldwide Forums | Help | Site Map

Table update problem

Newbie
 
Join Date: Jan 2008
Posts: 5
#1: Jan 2 '08
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.GetUserName()
DoCmd.RunSQL "UPDATE tblEmployees SET [strEmpPassword]='" & Me.txtNewPassword.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.GetUserName() 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's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#2: Jan 2 '08

re: Table update problem


Get off the single quotes around MyID.
Newbie
 
Join Date: Jan 2008
Posts: 5
#3: Jan 2 '08

re: Table update problem


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
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#4: Jan 2 '08

re: Table update problem


You are welcome.

Best regards,
Fish
Reply