delete record

deb

Active Member
Joined
Feb 1, 2003
Messages
400
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
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
strings in raw sql must be quoted.
Code:
strSQL = "Delete * From t_Vendor WHERE Vendor= " & "'" & Me.VendorVariation.Value & "'"
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top