Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

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)
0
DatabaseDek
Asked:
DatabaseDek
  • 3
  • 2
  • 2
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
How is the record counter populated?

In many cases, I find it best to re-run the routine that populates those sort of values directly, instead of refreshing/requerying the form.

For example, if I'm running a DCount to populate a textbox, I'd just run that DCount directly again when I need to:

Me.Parent.txRecCount = DCount("SomeField", "SomeTable", "SomeField=SomeValue")
0
 
Dale FyeCommented:
No points please, I'm like Scott, I like to explicitly call the code that does that type of thing.  If there are several steps that need to be performed, put it in a subroutine in the forms code module and simply call it after the delete.

Depending on how you are deleting the record, you might use the "AfterDelConfirm" event for the form to call this code.
0
 
DatabaseDekAuthor Commented:
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
 
Dale FyeCommented:
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
0
 
DatabaseDekAuthor Commented:
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.
0
 
DatabaseDekAuthor Commented:
Thanks both
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now