Requery subform

R

RBDU

Hi All! Thanking anyone for a reply. A97

I have a database to log searches and some of course are marked incomplete.

On my opening form I placed a subform made from a query that counts the
incomplete records and displays a message giving the total of incomplete
search incidents. Which works well, except!

When the user marks one of the incomplete incidents as completed on the
relevant form and closes that form, they return to the main form. But the
subform on the opening form gives the original count not the updated count.
Which should be minus 1.

What coding could I use on the main form or the subform, so when the user
closes the incomplete searches form, the subform gives the correct tally? At
the moment it only gives the correct count when I close the database and
later reopen it.

Regards
Peter McCartney
 
A

Allan Murphy

Try this, you could put a button called Update or Refresh Data on your Main
Form
then on the Click event of the of the button enter the following code

docmd.requery "your subform name"
 
A

Allen Browne

Requery your subform in the Close event of your search form.

Set the form's On Close property to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.

Enter this line between the 2 Access gives you:
Private Sub Form_Close()
Forms![Form1]![Sub1].Form.Requery
End Sub
replacing "Form1" with the name of your main form, and "Sub1" with the name
of your subform control.

That code will give an error if the other form is not open, so if you are
using Access 2000 or later you might like to extend it to:
Private Sub Form_Close()
If CurrentProject.AllForms("Form1").IsLoaded Then
Forms![Form1]![Sub1].Form.Requery
End If
End Sub
 
R

RBDU

Thanks Guys
Regards Peter

Allen Browne said:
Requery your subform in the Close event of your search form.

Set the form's On Close property to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.

Enter this line between the 2 Access gives you:
Private Sub Form_Close()
Forms![Form1]![Sub1].Form.Requery
End Sub
replacing "Form1" with the name of your main form, and "Sub1" with the name
of your subform control.

That code will give an error if the other form is not open, so if you are
using Access 2000 or later you might like to extend it to:
Private Sub Form_Close()
If CurrentProject.AllForms("Form1").IsLoaded Then
Forms![Form1]![Sub1].Form.Requery
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

RBDU said:
Hi All! Thanking anyone for a reply. A97

I have a database to log searches and some of course are marked
incomplete.

On my opening form I placed a subform made from a query that counts the
incomplete records and displays a message giving the total of incomplete
search incidents. Which works well, except!

When the user marks one of the incomplete incidents as completed on the
relevant form and closes that form, they return to the main form. But the
subform on the opening form gives the original count not the updated
count.
Which should be minus 1.

What coding could I use on the main form or the subform, so when the user
closes the incomplete searches form, the subform gives the correct tally?
At
the moment it only gives the correct count when I close the database and
later reopen it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top