Papa Dilbert
Papa Dilbert

Reputation: 23

Access VBA Form current record is deleted

I'm using Access 2003.

I have a form (FormA) that displays the fields of a row in TableA. On the form I have a button that opens a dialog with a listbox that lists all of the rows of TableA. A delete button on the dialog form allows the user to delete a selected row from the TableA, The user then closes the window and is returned to FormA.
If the user deleted the currently viewed row, the fields on the form show #DELETED.
I coded a Me.Form.Requery upon returning from the dialog. When it executes I get a runtime error that the record is deleted. Instead of the error, I expected the form to requery and reposition the current record.
I have code in Sub Form_Current(). Just to see if that was affecting the requery process I commented it out. Now the form is requeried as expected.

It seems that existence of Form_Current() prevents the requery. I tried coding a Me.Requery in Form_Current and all I did was loop. The code I have in Form_Current() requeues subforms. So it's a requirement that the form gets requeued before requesting a requeue of the subforms.

Is there a way to requeue the before Form_Current() gets called? Is there a better approach?
Where have I gone wrong?

Upvotes: 0

Views: 1249

Answers (1)

Fionnuala
Fionnuala

Reputation: 91346

It would be better to put the requery in the dialog:

Forms!FormA.Requery

Upvotes: 1

Related Questions