In some cases you might want to activate a form given its name, but VB doesn’t let you do it directly. However, it is easy to create a function that does it by iterating over all the forms in the current project:
' retrieve a reference to a form given its name' if there are multiple occurrences of a form, it' retrieves the first occurrence in the Forms collectionFunction GetForm(ByVal formName As String) As Form Dim frm As Form For Each frm In Forms If StrComp(frm.Name, formName, vbTextCompare) = 0 Then Set GetForm = frm Exit Function End If NextEnd Function