Updating continuous form after deleting record

alegatzke

New member
Local time
Today, 12:24
Joined
Oct 29, 2015
Messages
5
Hi,

I have a continuous form that serves as a list of items. When a user selects a record, a new form opens that allows you to edit or delete the item. My problem is that I want the continuous form to update as soon as a record is deleted from the other form.

Currently, when a record is deleted, the continuous form shows "Deleted" in all fields. As soon as I refresh the continuous form manually it removes the deleted record. Is there a way to automate this process so that my users will never see a deleted record in the continuous form?

I also never want the continuous form to close at any point. The only form that closes is the form used for editing records.

Here's the OnClick event of my delete button currently:

Code:
Private Sub btnDeleteItem_Click()
If MsgBox("Do you want to delete this item from the list? (Only delete if item is not considered valuable)", vbYesNo, "Delete Confirmation") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord
End If

End Sub
 
Forms!nameOfThatForm.Requery

But more trickery is needed, if you want to stay on a specific record and not just display record 1 after requery.
 
Forms!nameOfThatForm.Requery

But more trickery is needed, if you want to stay on a specific record and not just display record 1 after requery.

I don't need to display a specific record, this worked perfectly for deleting the item.

I would also like to have the same thing happen when I add a new record to my continuous form. I tried setting the same code in my OnClick event for the save button, but it isn't working correctly. When I add a new item to the list, it won't show up until I manually refresh the page even though it should be requerying. Any ideas why?

Here's the relevant portion of the code.

Code:
DoCmd.Save


MsgBox "Record saved, the item number is '" & strItemNum & "'. Returning to list."

Forms![LostItemsList].Requery
DoCmd.Close acForm, "Lost Item"
 
docmd.save does NOT save the record, but form changes. You really really need to read the online documentation for this sort of thing.

You need docmd.runcommand acsomethingorothergoogleit, probably acsaverecord
 
docmd.save does NOT save the record, but form changes. You really really need to read the online documentation for this sort of thing.

You need docmd.runcommand acsomethingorothergoogleit, probably acsaverecord

You're right, that was a dumb mistake for me to make. At least it was an easy fix with your advice. Everything is working correctly now, thanks for the help again!
 

Users who are viewing this thread

Back
Top Bottom