Link to home
Start Free TrialLog in
Avatar of Derek Brown
Derek BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Update parent form

I have a continuous subform with a record counter on the main form.

When I delete a record from the subform the record counter on the main form does not update immediately.

I have requery and refresh  just about every where but it will not update until I close and reopen.

How can I be programming with access for 20 years and not answer this stupid question. Why is something so basic so difficult in access (2002)
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Derek Brown

ASKER

Hi both

From the subforms on delete proceedure I have tried

Private Sub Form_Delete(Cancel As Integer)
Me.Refresh
Forms![SetsMain]![Text7].SetFocus
Me.Refresh
Forms![SetsMain]![Text7] = DCount("[DoorNumber]", "SelectSet")
End Sub

I have also tried the on delete confirm but as I disabled warnings that does not work either. I just don't get it.

If I open the selected query it shows the correct number of records but not when I call it from the form.

Whilst writing this it has occurred to me that perhaps it is not working because I am using the same query that is the underlying query for the subform. Maybe that is the problem?

Derek
Whilst writing this it has occurred to me that perhaps it is not working because I am using the same query that is the underlying query for the subform. Maybe that is the problem?
Could be, but that's hard to say. In my opinion, you're much better off going directly back to the source, so if "SelectSet" is a query, then go back to the underlying tables and get the data from those instead of the query.
Sometimes, I'll put code like that in the timer event and set the timer interval to something like 100.  Then, in the Timer event, I'll set the interval back to zero and run the code.  

So, put this in the Delete event of the subform:

Private Sub Form_Delete(Cancel as Integer)

    debug.print "Delete"
    me.Parent.TimerInterval = 100

End Sub

Then, in the Timer Event of the main form:

Private Sub Form_Timer()

    me.TimerInterval = 0
    me.[Text7] = DCount("[DoorNumber]", "SelectSet")

End Sub
Thank you both.

It was indeed the underlying query that was the problem. Copied it called it version 2 and referred to that instead of the subforms original and Bingo!!

What a crazy world Access sometimes is.
Thanks both