delete record
Results 1 to 2 of 2

Thread: delete record

  1. #1
    Board Regular
    Join Date
    Feb 2003
    Posts
    392
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default delete record

    Acess 365

    I have a form called vendor (shows a list of Vendors), with a subform called VendorVariable (to add a Vendor that is in the t_Vendor table to the t_VendorVariable table. I then want the Vendor added to the t_VendorVariable table via the subform to delete the same Vendor from the t_Vendor Table.

    I am trying to end up with two tables separating the Vendors with the similiarly named vendors....
    FYI the Vendors added to the t_VendorVariable table via the subform are Vendors that are the same but are spelled differently. i.e. st.Joseph and Saint Joseph.

    When I add a record in the subform I want it to automatically delete the Vendor record from the t_Vendor table where the VendorVariable is the one just added via the subform.

    In other words if a new Vendor record is added to t_VendorVariable, the vendor with the same name should be deleted from the t_Vendor table.

    How and where do I add the delete code?

    I tried putting at the save button of the subform. I pops up a "Enter Parameter Value" box for the Vendor Name that was entered

    Private Sub btnSave_Click()
    On Error GoTo btnSave_Click_Err

    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    If (MacroError <> 0) Then
    Beep
    MsgBox MacroError.Description, vbOKOnly, ""
    End If

    DoCmd.SetWarnings False
    strSQL = "Delete * From t_Vendor WHERE Vendor= " & Me.VendorVariation.Value
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True

  2. #2
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    16,445
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: delete record

    strings in raw sql must be quoted.
    Code:
    strSQL = "Delete * From t_Vendor WHERE Vendor= " & "'" & Me.VendorVariation.Value & "'"

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •