Results 1 to 7 of 7
  1. #1
    looloo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    36

    Update syntax

    What is the code for updating a field using the contents of a control entered in a form?



    Thank you.

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    In SQL:

    Update TableNameHere Set FieldNameHere = [Forms]![FormNameHere]![ControlNameHere]

    --------------------------------------------

    In VBA:

    "Update TableNameHere Set FieldNameHere = " & Forms!FormNameHere.ControlNameHere

    and if it is text it would need:

    "Update TableNameHere Set FieldNameHere = " Chr(34) & Forms!FormNameHere.ControlNameHere & Chr(34)

    or for dates

    "Update TableNameHere Set FieldNameHere = #" & Forms!FormNameHere.ControlNameHere & "#"

  3. #3
    looloo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    36
    Thanks for the quick response! I'm working in VB. That example didn't work. Trying variations now..

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    What exactly didn't work when you tried samples that Bob gave?

  5. #5
    looloo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    36
    It gives me a generic syntax error.

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Post the EXACT SQL you are attempting to use and also tell us what datatype each of your fields is.

  7. #7
    looloo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    36
    Thanks! I got it with a little trial and error. I see what you were trying to say, but I was in too much of a hurry to slow down and figure it out.

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

Similar Threads

  1. Syntax Error on Update Statment
    By TinaCa in forum Programming
    Replies: 2
    Last Post: 09-14-2011, 05:53 PM
  2. UPDATE Statement Correct Syntax
    By OMGsh Y did I say Yes in forum Forms
    Replies: 2
    Last Post: 02-23-2011, 01:42 PM
  3. sql UPDATE syntax help
    By ducthang88 in forum Programming
    Replies: 1
    Last Post: 12-04-2010, 12:12 PM
  4. UPDATE query syntax
    By jgelpi16 in forum Programming
    Replies: 10
    Last Post: 08-21-2010, 07:40 PM
  5. Syntax For After Update Event
    By MuskokaMad in forum Forms
    Replies: 14
    Last Post: 03-12-2010, 01:48 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