Loop through all Open forms and requery (1 Viewer)

sambo

Registered User.
Local time
Today, 05:48
Joined
Aug 29, 2002
Messages
289
I am trying to requery all of the subforms in my tab control when information from a certain unbound form is entered into the tables. Here is what I have so far, but it doesn't seem to want to cooperate.

Dim myObj As AccessObject, db As Object
Set db = Application.CurrentData 'get the current db data

For Each myObj In db.AllForms 'loop through all open forms
On Error Resume Next
If myObj.IsLoaded Then 'if the form is open
myObj.Requery 'requery the recSource (same as SHIFT + F9)
End If
Next myObj 'loop through all forms


I get the error, 'Object doesn't support this property or method' at the For Each Line.

Any Suggestions
 

Richio

Registered User.
Local time
Today, 13:48
Joined
May 31, 2002
Messages
75
I had a similar problem which was fixed by checking all open forms and refreshing / requery.

Unfortunately I can't remember exactly what was done. Try doing a search of the forums under my richio name.

Hope you find it and it solves the problem
 

sambo

Registered User.
Local time
Today, 05:48
Joined
Aug 29, 2002
Messages
289
I didn't find anything similar under that name.
Still need help with the problem.
 

sambo

Registered User.
Local time
Today, 05:48
Joined
Aug 29, 2002
Messages
289
Got it to work, here is the code for future reference...

Dim frm As Form
For Each frm In Application.Forms
If IsLoaded(frm.Name) = True Then
' requery and then refresh the form
frm.Requery
frm.Refresh
End If
Next frm
 

Users who are viewing this thread

Top Bottom