Append/Delete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • delboy39
    New Member
    • Dec 2013
    • 2

    Append/Delete

    Hi All, have just found and joined this forum. Bit of background - am 74yrs using m/s office pro 2003 self taught. Using access for small club database. I have a command button on a switchboard that I want to append members details to another database and then delete the record from the current database (member leaves club or is deceased). Am using a combo box to select the record to append/delete but am having a problem with vba code. Briefly -
    Code:
     DoCmd.SetWarnings True
    
           DoCmd.RunSQL "INSERT INTO LDMRC_Deleted_Members (Name_Prefix,First_Name,Last_Name,Address_1,Address_2,Address_3,Town,Post_Code,Tel_No,Mobile_No,E_Mail,Notes) Values ('" & Me.Combo4.Column(1) & "','" & Me.Combo4.Column(2) & "','" & Me.Combo4.Column(3) & "','" & Me.Combo4.Column(4) & "','" & Me.Combo4.Column(5) & "','" & Me.Combo4.Column(6) & "','" & Me.Combo4.Column(7) & "','" & Me.Combo4.Column(8) & "','" & Me.Combo4.Column(9) & "','" & Me.Combo4.Column(10) & "','" & Me.Combo4.Column(11) & "','" & Me.Combo4.Column(12) & "')"
    
    DoCmd.RepaintObject
    
    DoCmd.RunSQL "DELETE FROM LDMRC_Table1 WHERE Membership_No = ('" & Me.Combo4.Column(1) & "')"
    
    End Sub
    The append bit works ok but can not get delete part to work.

    Would appreciate any help
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    you do not need the '()' in:
    Code:
     DoCmd.RunSQL "DELETE FROM LDMRC_Table1 WHERE Membership_No = ('" & Me.Combo4.Column(1) & "')"
    change to:
    Code:
     DoCmd.RunSQL "DELETE FROM LDMRC_Table1 WHERE Membership_No = '" & Me.Combo4.Column(1) & "'"
    The single quotes around Me.Combo4.Colum n(1) are only needed if it's an alpha field.
    If it's numeric, than they are not needed too.

    Comment

    • delboy39
      New Member
      • Dec 2013
      • 2

      #3
      Thanks Luuk for your reply. Have not altered my code yet as per your reply, having been away for Christmas/New year. Hoping to do that shortly and will advise if works OK.

      Delboy39

      Comment

      Working...