I've copied some code from the Access 2007 VBA examples for opening multiple form instances. It works when I open the example db, but gives me a "User-defined type not defined" when I use it. I have looked at the references from the example db, and made sure that I have VB for Apps, MS Access 12.0 Object Library, OLE Automation, and MS Office 12.0 Access database engine Object in my references.
When I try to open a form with this code, it seems to fail on the "New Form_" bit.
Can anyone help me figure out why this won't work, or suggest a better way to do it?
When I try to open a form with this code, it seems to fail on the "New Form_" bit.
Code:
Option Compare Database
Option Explicit
'This sample demostrates how to use multiple instances of a form.
'Declaring global variable to create collection
'to hold multiple instances of a form.
Private mcolFormInstances As New Collection
Function OpenFormInstance(FormName As String, Optional WhereCondition As String, Optional SetEnable As Boolean)
'Declare the Form Object
Dim frm As Form
Select Case FormName
Case "frmInvDetail"
Set frm = New Form_frmInvDetail
Case Else
Debug.Assert False
End Select
'set the filter properties on the form.
If WhereCondition <> "" Then
frm.Filter = WhereCondition
frm.FilterOn = True
End If
'Now make the form visible.
frm.Visible = True
' Need to keep a reference to the form so that it doesn't immediately
' close when the frm variable goes out of scope.
mcolFormInstances.Add frm
End Function
Can anyone help me figure out why this won't work, or suggest a better way to do it?