Hi

Vugar

Registered User.
Local time
Tomorrow, 01:13
Joined
Sep 15, 2015
Messages
55
Hi everyone,

could you please tell can I write sum rule that when I close some form, the other forms that opened will refresh data automatically

Thank you
 
put this in a Module:

Code:
Public Function IsFormLoaded(ByVal strFormName As String) As Boolean
    Dim oAccessObject As AccessObject
    On Error Resume Next
    Set oAccessObject = CurrentProject.AllForms(strFormName)
    IsFormLoaded = False
    If oAccessObject.IsLoaded Then
        If oAccessObject.CurrentView <> acCurViewDesign Then IsFormLoaded = True
    End If
    Set oAccessObject = Nothing
End Function

Public Sub RequeryAllOpenForms(Optional Byval strFormToExclude As String = "")
Dim var As Variant
For Each var In CurrentProject.AllForms
    If var.Name <> strFormToExclude Then
        If IsFormLoaded(var.Name) Then Forms(var.Name).Requery
    End If
Next var
End Sub
now on unload or close event of your form you can call RequeryAllOpenForms:

private sub form_load()
'don't include this form that is closing
RequeryAllOpenForms Me.Name
end sub
 
Could you please tell if you have simple method to refresh all data when I will close some form?

And one more my main form with (Month) field Me.Requery
 
Last edited:

Users who are viewing this thread

Back
Top Bottom