I'm trying to make a loop which runs for every form excluding the activeform... I found a solution which I could use ActiveForm.ActiveMdiChild.Name = FormRefresh.Name
but the problem is if I've 2 forms of same name, It'll not loop in the not active form...
Public Shared Sub VerificaAlterações()
For Each FormRefresh As Form In Application.OpenForms()
If ActiveForm.ActiveMdiChild = FormRefresh Then Continue For ' Error here
' Do some work...
Next
End Sub
Edit: The problem was the Shared
in Sub... I removed it and it worked with the answer below.
CodePudding user response:
There's no need to compare the names of the forms when you can compare the forms themselves:
If FormRefresh Is ActiveMdiChild Then Continue For