Results 1 to 2 of 2
  1. #1
    subtilty is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    4

    Updating record SQL/VBA

    Hi All,

    I am trying to made a button to update the fields on my form.

    I developed this but I am guessing it's wrong as getting a 3075 error on it.



    Any help would be great please

    Code:
    CurrentDb.Execute "UPDATE calldata " _& "SET username =  & Me.username & " ','" & _
    & "SET reportdate = Me.reportdate & " ','" & _
    & "SET registration = Me.registration & " ','" & _
    & "SET vin =  & Me.vin & " ','" & _
    & "SET vehmodel =  & Me.vehmodel & " ','" & _
    & "SET vehengine =  & Me.vehengine & " ','" & _
    & "SET vehfuel =  & Me.vehfuel & " ','" & _
    & "SET vehtrans =  & Me.vehtrans & " ','" & _
    & "SET custtype =  & Me.custtype & " ','" & _
    & "SET custname =  & Me.custname & " ','" & _
    & "SET custtel =  & Me.custtel & " ','" & _
    & "SET custemail =  & Me.custemail & " ','" & _
    & "SET custconcern =  & Me.custconcern & " ','" & _
    & "SET cc =  & Me.cc & " ','" & _
    & "SET as =  & Me.as & " ','" & _
    & "SET centre =  & Me.centre & " ','" & _
    & "WHERE reportnumber =  & Me.reportnumber & "')"

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Missing quote marks, apostrophe and # delimiters missing or in wrong place, space in front of second apostrophes, don't repeat SET, don't double up the &:

    CurrentDb.Execute "UPDATE calldata " & _
    "SET username = '" & Me.username & "', " & _
    "reportdate = #" & Me.reportdate & "#, " & _
    "registration = '" & Me.registration & "', " & _
    "vin = '" & Me.vin & "', " & _
    "vehmodel = '" & Me.vehmodel & "', " & _
    "vehengine = '" & Me.vehengine & "', " & _
    "vehfuel = '" & Me.vehfuel & "', " & _
    "vehtrans = '" & Me.vehtrans & "', " & _
    "custtype = '" & Me.custtype & "', " & _
    "custname = '" & Me.custname & "', " & _
    "custtel = '" & Me.custtel & "', " & _
    "custemail = '" & Me.custemail & "', " & _
    "custconcern = '" & Me.custconcern & "', " & _
    "cc = '" & Me.cc & "', " & _
    "as = '" & Me.as & "', " & _
    "centre = '" & Me.centre & "', " & _
    "WHERE reportnumber = '" & Me.reportnumber & "')"

    If any of the fields are number datatype, remove the apostrophes.
    Why are you doing this? Are you not using bound form to edit records?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Navigation Bar Record Count not updating
    By ylatodd in forum Forms
    Replies: 27
    Last Post: 02-13-2012, 10:45 AM
  2. Replies: 1
    Last Post: 02-02-2012, 08:34 PM
  3. Updating a record with a value through a macro
    By jlgray0127 in forum Programming
    Replies: 1
    Last Post: 10-06-2011, 02:34 PM
  4. SQL not updating record
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 01-27-2011, 10:42 AM
  5. updating a record
    By markjkubicki in forum Programming
    Replies: 18
    Last Post: 09-19-2010, 08:20 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
  •  
Other Forums: Microsoft Office Forums