I have some code that runs some code to add a foreign key to a sub-sub-form. To refresh the foreign key data I also run a requery. The code also saves the record. The sub-sub-form is now reset back to the first record of the related records.
- The problem I have is that regardless of which line's Delete button I click, the first record gets deleted - not good.
- If I select into the record, then click a delete button, it works correctly. However, if I back out (check NO) after selecting a record and click delete, I am presented with only the selected record and the following records - even though all are still there. This will freak out my users. I have tried requery , but either I am doing something wrong or it it the wrong way to do it. How do I show all records after this process?
Code:
Private Sub delLine_Click()
On Error GoTo Err_delLine_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_delLine_Click:
Exit Sub
Err_delLine_Click:
' MsgBox Err.Description
Resume Exit_delLine_Click
' Requery to refresh data
Me.[Conferences subform1].Form.Requery
End Sub
Private Sub Statement_Enter()
' apply foreign key upon entering subform field
Me.TradeAssocID = Me.fkTradeAssocID
End Sub
Private Sub Statement_Exit(Cancel As Integer)
' Save record upon exit of subform field
' Run update query to add key to bridge table
' On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
CurrentDb.Execute "Qupd", dbFailOnError
End Sub