How to use requery here

  • Thread starter Thread starter GaryS
  • Start date Start date
G

GaryS

Here's my situation:

Form A uses information from Table X.

From Form A, I can get to Form B, which updates Table X.

When I return to Form A, how can I force the updated info
to automatically appear on Form A?

I assume there's a requery involved, but I don't know in
which object and which event to put the requery.

Thanks.

GaryS
 
Hi,
If you're closing FormB, then put it in that form's close event.
You have to be a bit careful here if FormB can be opened on it's own.
Use the IsLoaded function from the Northwind db to make sure FormA
is open before you requery it.

If FormB remains open, it's a bit trickier. You could try the activate event of
Form A but you would only want that to fire if you're returning to FormA from FormB.
You could have a public boolean variable indicating whether FormA should be requeried.

Set it to true at some point/event in FormB and then check it in FormA's activate event.

That's all I could think of. Perhaps someone has a simpler solution :-)
 
Thanks for the details, Dan! I think I understand what
you're saying.

I checked the Access Help on Requery. It says it only
works on the active object (in this case, FormB) unless I
use the Requery Method in a VBA routine. Since I want to
requery FormA, it looks like I'll have to use the Method.

This is getting deep (for me): The actual data I want
refreshed in FormA is in one of its subforms;
specifically, I want to see the row that FormB added.

So . . . do I requery the query on which the subform is
based? How do I write that?

The example I'm looking at is directly out of Help:

Sub RequeryList()
Dim ctlList As Control

' Return Control object pointing to list box.
Set ctlList = Forms!Employees!EmployeeList
' Requery source of data for list box.
ctlList.Requery
End Sub

But the object I want to requery is not a list box, so I
need some help on how what I want to do would look
different.

Gary
-----Original Message-----
Hi,
If you're closing FormB, then put it in that form's close event.
You have to be a bit careful here if FormB can be opened on it's own.
Use the IsLoaded function from the Northwind db to make sure FormA
is open before you requery it.

If FormB remains open, it's a bit trickier. You could try the activate event of
Form A but you would only want that to fire if you're returning to FormA from FormB.
You could have a public boolean variable indicating
whether FormA should be requeried.
Set it to true at some point/event in FormB and then
check it in FormA's activate event.
 
Dan,

I don't see any harm in putting a Requery in FormA's
Activate event. I'll give it a try.

Gary

-----Original Message-----
Hi,
If you're closing FormB, then put it in that form's close event.
You have to be a bit careful here if FormB can be opened on it's own.
Use the IsLoaded function from the Northwind db to make sure FormA
is open before you requery it.

If FormB remains open, it's a bit trickier. You could try the activate event of
Form A but you would only want that to fire if you're returning to FormA from FormB.
You could have a public boolean variable indicating
whether FormA should be requeried.
Set it to true at some point/event in FormB and then
check it in FormA's activate event.
 
Back
Top