runsql update error with date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TriednTested
    New Member
    • Apr 2007
    • 1

    runsql update error with date

    Hello
    I have a subform and to edit the data I place it on the main form where changes can be made, then a cmd button is used to execute the docmd.runsql update query. However I am constantly getting an error msg (syntax error in UPDATE statement). Here is my code:
    Code:
    updateSQL = "UPDATE Assistance SET " & _
    "Date =" & editDatetxt & ", "  & _
    "Assistance ='" & Me.aAssistancetxt & "', " & _
    "Amount =" & Me.aAmounttxt & " " & _
    "WHERE assistanceID =" & Me.aAIDtxt
    
    DoCmd.RunSQL updateSQL
    I have located the cause of the error to the line ["Date=" & editDatetxt & ", " & _ ] I have tried adding ' and # around editDatetxt but I keep getting the error. Assistance.date is formated as date/time (short date) and editDatetxt is also formatted to short date.
    Any help greatly appreciated.
    TIA
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Try this ...

    Code:
    updateSQL = "UPDATE Assistance SET " & _
    "Date =#" & Me.editDatetxt & "#, "  & _
    "Assistance ='" & Me.aAssistancetxt & "', " & _
    "Amount =" & Me.aAmounttxt & " " & _
    "WHERE assistanceID =" & Me.aAIDtxt
    
    DoCmd.RunSQL updateSQL
    Also change the name of the Date field to something else and Date is a function in Access and this might be causing a problem.

    Mary

    Comment

    Working...