Results 1 to 7 of 7
  1. #1
    moises is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    15

    error in updating the record in table

    hi guys,

    i have a separate button to update the record, but when i run or click the cmdUpdate button it gives me an error;

    code below is the one i'm working thru.

    Private Sub cmdUpdate_Click()

    strSQL1 = "UPDATE tblAMHMace " & _


    " SET ReferenceNo=" & Me.txtReferenceNo & "'" & _
    ", DateLog='" & Me.txtDate & "'" & _
    ", DocType='" & Me.txtDocType & "'" & _
    ", Subject='" & Me.txtSubject & "'" & _
    ", Recipient='" & Me.txtRecipient & "'" & _
    ", Company='" & Me.txtCompany & "'" & _
    ", Initiator='" & Me.cboInitiator & "'" & _
    ", Status='" & Me.cboStatus & "'" & _
    ", PreparedBy='" & Me.txtPreparedBy & "'" & _
    ", WHERE ReferenceNo=" & Me.txtReferenceNo.Tag

    If Me.txtReferenceNo.Tag & "" = "" Then

    MsgBox "Record exist", , ""

    Else

    rs.Edit
    db.Execute strSQL1, dbFailOnError
    rs.Update
    rs.MoveNext

    MsgBox "Record has been updated...", vbInformation + vbOKOnly, "Database Information"

    DoCmd.Close acForm, Me.Name

    End If

    End Sub
    Attached Thumbnails Attached Thumbnails Run-time error '3075'.png  

  2. #2
    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,725
    Must have matching quotes.
    If you have a quote within a string, you must double that quote.

    ....Manager's .... should be .....Manager''s.....

    See this for more info

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    I use Replace() function to manage this issue in construction of SQL statements. So as example, if field contains data like "O'Hare", the code would be:

    "UPDATE tablename SET fieldname ='" & Replace(Me.cbxName, "'", "''") & "' WHERE
    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.

  4. #4
    moises is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    15
    Hi guys,

    Sorry for late reply. I use REPLACE() query but still not working.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    If you want to provide db for analysis, follow instructions at bottom of my post.

    Why are you using UPDATE action anyway? Why not editing record on bound form?
    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.

  6. #6
    moises is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    15
    Hi june7,

    Thanks for the instruction, i use editing record in bound form and it works.

    But i still trying to make the updating query work, i have a query in inserting and deleting record but not in the editing records. thanks...

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Date/time type fields require # delimiter for value.

    ", DateLog=#" & Me.txtDate & "#" & _
    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. Replies: 9
    Last Post: 12-25-2014, 12:38 AM
  2. New record error in form, but not table
    By bigsich in forum Access
    Replies: 6
    Last Post: 09-30-2013, 01:15 PM
  3. Replies: 2
    Last Post: 03-26-2013, 12:00 PM
  4. Record Selection, email and then table updating
    By ballj_35 in forum Programming
    Replies: 4
    Last Post: 10-05-2010, 01:41 PM
  5. Updating another record table with command button
    By erlan501 in forum Programming
    Replies: 5
    Last Post: 04-26-2010, 09:03 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