Originally Posted by
hansendl
Try running the code without the line "frm.Visible = False". By default, I believe forms instantiated in code are not visible until you explicitly make them visible. I create dialog forms like this frequently in code where I instantiate the form, set a bunch of properties, then make it visible by setting frm.Visible = True. Until I actually run that line of code, the form is loaded, but remains invisible.
Example:
Code:
Private WithEvents dlg As Form_frmOrgPickDialog
Private Sub SelectOrg(cbo As Access.ComboBox)
Set dlg = New Form_frmOrgPickDialog
With dlg
.ExpansionLevel = 2
.DisplayOrgType = otSelect
.BuildTree
If Not IsNull(cbo) Then
.ActiveNode = "o" & cbo.Value
End If
End With
dlg.Visible = True
End Sub
yeah it still does it (flick from unfiltered to filtered)
my code
Code:
'Open a new instance, show it, and set a caption.
Dim frm As Form
Set frm = New Form_frmSchoolsFound
Dim strNewSQL As String
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs(frm.RecordSource)
strNewSQL = qdf.SQL
Set qdf = Nothing
strNewSQL = Replace(strNewSQL, "WHERE " & Chr(40) & Chr(40) & Chr(40) & "tblSchools.Removed" & Chr(41) & " Is Null" & Chr(41) & Chr(41), "")
With frm
.RecordSource = strNewSQL
.Filter = strWhere
.FilterOn = True
.Caption = IIf(IsNothing(frm.Form!SchoolName), "no name", frm.Form!SchoolName) '"Schools Found" &
End With
If cycleFoundSchools(frm.Form!NewSchoolsID) Then
MsgBox "School " & IIf(IsNothing(frm.Form!SchoolName), "no name", frm.Form!SchoolName) & " is already open, the opening form will close."
Else
'Append it to our collection.
clnClient.Add Item:=frm, Key:=CStr(frm.Hwnd)
End If
frm.Visible = True
Set frm = Nothing
note updated for easier viewing