How to delete a record from two subforms simultaneously?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #1

    How to delete a record from two subforms simultaneously?

    I have 2 subforms on a form in a tab control that are virtually the same, except the one starts with a code of an item and the other one with a description should you not have a code.
    I want to use this code below to delete a record from both subforms at the same time.
    How do i amend the code and add the 2nd subform called "Fis_MonthcntSF " to it?

    Code:
    Private Sub DeleteEntry_Click()
    On Error GoTo DeleteEntry_Click_Err
    Me.Fis_StocktakeSF.SetFocus
    With Me.Fis_StocktakeSF
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    DeleteEntry_Click_Exit:
        Exit Sub
    
    DeleteEntry_Click_Err:
        MsgBox Error$
        Resume DeleteEntry_Click_Exit
    End With
    
    End Sub
    pls help
  • Sharkiness
    New Member
    • Sep 2008
    • 19

    #2
    Are these two items linked at all by a unique ID?

    If so then through the relationships you need to make sure there is a relationship between the two, then click enforce referential integrity and click cascade delete related records.

    Save the relationship. Then when you delete one the other should delete

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      The underlying query is the same, just the layout of the fields are different. i was hoping to add another line to the above code to include this subform where the data must be deleted.
      The reason i want to do this, is that you either use the Fis_StocktakeSF or the Fis_MonthcntSF subforms, and not both at the same time.
      It depends on whether you want to add the item by its description or by the item code.
      You wont lookup the item in both subforms. I want to use this code to delete the last line that you captured in whichever subform you were using. Perhaps the focus should be set on the subform in use ,in this tab control. hope it makes sense!

      Comment

      Working...