Results 1 to 11 of 11
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question UPDATE query syntax

    Can someone provide the syntax, or an place I can find it, for an update query using:

    Code:
        'mySQL = ("UPDATE myTable")
        CurrentDb.Execute mySQL, dbFailOnError
    Thank you!!

    This is what I have but it isn't working...
    Code:
    mySQL = ("UPDATE AcctPeriod SET RV = '" & varRACF & "' WHERE Auto >= '" & varBegNum & "' AND Auto <= '" & varEndNum & "'")
    CurrentDb.Execute mySQL, dbFailOnError


  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you done a MsgBox ">" & mySQL & "<" to see what you actually get?

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    No, but it seems to be working fine now...
    Code:
        mySQL = ("UPDATE AcctPeriods SET AcctPeriods.RV = '" & varRACF & "' WHERE AcctPeriods.Auto>=" & varBegNum & " AND AcctPeriods.Auto<=" & varEndNum & "")
        CurrentDb.Execute mySQL, dbFailOnError

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Don't you just love it when problems just go away on their own? Were you getting a syntax error or just throwing a runtime error when it ran? It could be a data driven problem.

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    haha, yea! It was getting an error stating "Object required" Can't remember the number though.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If a problem goes away on its own, it will probably come back on its own. I still suspect a data issue. Are you certain there is *always* valid data in the variables when you run the query?

  7. #7
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Well currently there has to be as I am typing the data in. The variables are based on text boxes and a combo box. I can't imagine what had caused the error the first time unless I had missed a " ' " or something when I typed the code the first time.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Not easy to tell that with the info supplied so far. Your ComboBox is bound to the Column you want right? Just taking shots at the issue from the hip.

  9. #9
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Yea it is, and it should matter as it is just appending the value to the table. I'm not grouping on the combo box value or anything like that.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Happy computing then until next time.

  11. #11
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Thanks! You as well.

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

Similar Threads

  1. Syntax For After Update Event
    By MuskokaMad in forum Forms
    Replies: 14
    Last Post: 03-12-2010, 01:48 PM
  2. query syntax or design help ....
    By cowboy in forum Queries
    Replies: 1
    Last Post: 02-04-2010, 11:24 AM
  3. quick query syntax questions
    By cowboy in forum Access
    Replies: 6
    Last Post: 02-03-2010, 06:10 PM
  4. Syntax error (comma) in query expression
    By KLynch0803 in forum Programming
    Replies: 3
    Last Post: 01-18-2010, 03:35 AM
  5. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 AM

Tags for this Thread

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