0

Access 2010 here.

There are two tables in a 1-to-1 relationship (MainDB, Parts) and a command from the form (MainForm) that operates on the "Parts" table:

CurrentDb.Execute "DELETE * FROM Parts WHERE ID = ID", dbFailOnError
PartsForm.Requery

This would simply delete the entire "Parts" table and requery the subform working with that table (PartsForm). I'm just looking to delete a single record based on the ID of the currently selected record in "MainForm" from where the command is called. If there is a record with the same ID in the "Parts" table as the current record selected in "MainForm", this command should get rid of it on call.

Of course,

WHERE ID = ID

Is going to be the problem, but the command did not like references to fields available in "MainDB." How do you refer to the active record's ID through this command?

Thanks for the help. This seems like it should be a simple syntax fix.

Phizon
  • 93
  • 4
  • 14
  • Is Parts.ID a foreign-key to MainFormID? Perhaps table definitions would help. – ron tornambe Jan 30 '13 at 18:53
  • I think it was just a matter of syntax. There were no foreign keys defined. The parenthesis outside of a comma was my problem. Thank you for your help! – Phizon Jan 30 '13 at 19:35

1 Answers1

1
CurrentDb.Execute "DELETE * FROM Parts WHERE ID = " & Me.ID, dbFailOnError
PartsForm.Requery

Seemed to work, where extra parenthesis externally didn't.

Phizon
  • 93
  • 4
  • 14