Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh main form when record in subform deleted?

Status
Not open for further replies.

mudstuffin

Technical User
Sep 7, 2001
92
GB
Hello.

I am building an access xp db for my sports club which holds information about the matches, players, finances etc.

Within that I have a form with a subform on it which lists each match and I add in who played in that match. On the main form, I have a textbox which counts the records in the subform. However, I want the textbox to update when I add or delete a record to the subform. I have got it to work with the adding of records by using the afterupdate event, which triggers a dcount, but it wont work when deleting a record.

mainform = matchtable1
subform = PlayersPlayedTable Subform1

textbox holding the recordcount (on mainform) = PlayersPlayed

Can anyone tell me how I can do it....?

Thanks,


mudstuffin
 
How are ya mudstuffin . . . . .

Just move the [blue]DCount[/blue] function to the [blue]OnCurrent event[/blue] of the subform.

Calvin.gif
See Ya! . . . . . .
 
Thanks for that TheAceMan1.

Tried that but still not working. Doh....!

Maybe I need to change the way the dcount is getting the data i.e. its taking from the table, maybe I should run a query, then requery afterupdate event or something like that, as it seems that the data is not updating immediately on delete (tried running after the delete event too) ???

Thanks again.


mudstuffin
 
Have you tried to use the Requery or Refresh method in your main form.....
 
Thanks for that.

I thought I did try that, but had another go after you suggested it, and hey presto, its sorted it.

I put:-

Me.Parent.Requery
Me.Parent.Refresh

in the delete event of the subform, and placed it before the dcount, otherwise the delete event seems to pull data before its truly updated.

Cheers for the nudge.


Mudstuffin.
 
mudstuffin . . . . .

Have you tried the forms [purple]AfterDelConfirm Event?[/purple]
Code:
[blue]   If acDeleteOK Then
      [green]'Your DCount Assignment[/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top