Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting only record in Table

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
Using Access2003 I have a form that contains 1 sub form. There is a one to many relationship between the forms paretn and child links. When I try to delete the last record from the subform using the following code:
RunCommand acCmdDeleteRecord
The cursor stays in the subform and thus there is an empty record if I try to leave the form or go to a control in the main form I receive the error telling me it can't find the matching key fields. Is there a way to delete the last record in the subform and not have the new record in the subform. Just setting the focus to the main form doesn't work.

Thanks
 
If you are going to have the parent and child forms open, Access will look for a key field in both to link them together. Others may come up with a more efficient way of doing this, but a quick way to do this would be to add a blank record in both the parent and child tables. Then when you delete the last record that is not blank, you will not have a problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top