Results 1 to 5 of 5
  1. #1
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22

    How to find record in table with ID=1 and update its value.

    hi all,


    I want to find the record in the table Out_Inst_Val and set a field called Out_Inst_Val to the value in text144 for the record with ID=1.
    i tried the following code but am not sure whats wrong.

    Code:
    CurrentDb.Execute "UPDATE Out_Inst_Val SET [Out_Inst_Val] = text144 WHERE [ID] = 1"
    thanks.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    What is text144? The name of a control? What is the data type, text?

    CurrentDb.Execute "UPDATE Out_Inst_Val SET [Out_Inst_Val] = '" & Me.text144 & "' WHERE [ID] = 1"

  3. #3
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22
    Hi ItsMe,

    Text144 is a textbox which hold a string

    the code is mostly right except the part where u wrote '" & Me.text144 & "'.

    i made it
    Code:
    CurrentDb.Execute "UPDATE Out_Inst_Val SET [Out_Inst_Val] = 3 WHERE [ID] = 1"
    for a test and it works. I basically want the Out_Inst_Val to be equal to the value in text144 (in this case 3).
    thanks.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    3 looks like a Number type. I wrote the code for a Text type.

    Try
    CurrentDb.Execute "UPDATE Out_Inst_Val SET [Out_Inst_Val] = " & Me.text144 & " WHERE [ID] = 1"

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,915
    If this is true
    Quote Originally Posted by kassem View Post

    i made it

    Code:
    CurrentDb.Execute "UPDATE Out_Inst_Val SET [Out_Inst_Val] = 3 WHERE [ID] = 1"
    for a test and it works. I basically want the Out_Inst_Val to be equal to the value in text144 (in this case 3).
    then the line

    Quote Originally Posted by kassem View Post

    Text144 is a textbox which hold a string

    is obviously wrong, which is why

    '" & Me.text144 & "'

    wasn't correct! You have to give correct info when posting questions in order to get correct solutions!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 06-06-2014, 06:32 AM
  2. Replies: 6
    Last Post: 06-03-2014, 06:23 AM
  3. Replies: 1
    Last Post: 05-26-2014, 12:39 PM
  4. VBA: Find Record from in table from form
    By shimmy84 in forum Programming
    Replies: 6
    Last Post: 03-19-2012, 10:51 PM
  5. best way to find a record in a linked table
    By BRV in forum Programming
    Replies: 14
    Last Post: 11-10-2011, 09:31 AM

Posting Permissions

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