Z
zackelan
I have a document library application that has one main form and a
drill-down detail form. I need to be able to open the detail form from
two separate locations:
1. Select a record in the subform of the main form, click "View
details" command button
2. Double-click a line in the "related documents" listbox of the detail
form to open that document's detail view.
Since method #2 requires having multiple instances of the same form
open, I'm using a modified version of Allen Browne's OpenAClient
procedure (http://allenbrowne.com/ser-35.html):
Global gclnForms As New Collection
Sub OpenNewDetailForm(DocID As String)
Dim frm As Form
'Open a new instance, show it, and set a caption.
Set frm = New Form_frmDocument
frm.Visible = True
frm.Filter = "DocID = '" & DocID & "'"
frm.FilterOn = True
frm.Caption = "Document " & DocID
'Append it to our collection.
gclnForms.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing
End Sub
Here, frmDocument is the detail form, and DocID is the primary key of
the table of documents. I'm calling this code from my main form:
Private Sub cmdDetail_Click()
OpenNewDetailForm Form_sfrmMain.DocID
End Sub
And from the detail form itself:
Private Sub lstReferencedDocs_DblClick(Cancel As Integer)
OpenNewDetailForm Me.lstReferencedDocs
End Sub
When either of the code snippets above is run, I get an "Enter
parameter value" prompt asking for Forms!frmDocument!DocID. When I
trace the code, this prompt comes up immediately after running the "Set
frm = New Form_frmDocument" line in OpenNewDetailForm. I can hit either
OK (with or without something in the input box) or Cancel at the prompt
and the form loads as it should. The prompt doesn't come up at all if I
do a DoCmd.OpenForm "frmDocument".
I'd appreciate any help.
Zack
drill-down detail form. I need to be able to open the detail form from
two separate locations:
1. Select a record in the subform of the main form, click "View
details" command button
2. Double-click a line in the "related documents" listbox of the detail
form to open that document's detail view.
Since method #2 requires having multiple instances of the same form
open, I'm using a modified version of Allen Browne's OpenAClient
procedure (http://allenbrowne.com/ser-35.html):
Global gclnForms As New Collection
Sub OpenNewDetailForm(DocID As String)
Dim frm As Form
'Open a new instance, show it, and set a caption.
Set frm = New Form_frmDocument
frm.Visible = True
frm.Filter = "DocID = '" & DocID & "'"
frm.FilterOn = True
frm.Caption = "Document " & DocID
'Append it to our collection.
gclnForms.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing
End Sub
Here, frmDocument is the detail form, and DocID is the primary key of
the table of documents. I'm calling this code from my main form:
Private Sub cmdDetail_Click()
OpenNewDetailForm Form_sfrmMain.DocID
End Sub
And from the detail form itself:
Private Sub lstReferencedDocs_DblClick(Cancel As Integer)
OpenNewDetailForm Me.lstReferencedDocs
End Sub
When either of the code snippets above is run, I get an "Enter
parameter value" prompt asking for Forms!frmDocument!DocID. When I
trace the code, this prompt comes up immediately after running the "Set
frm = New Form_frmDocument" line in OpenNewDetailForm. I can hit either
OK (with or without something in the input box) or Cancel at the prompt
and the form loads as it should. The prompt doesn't come up at all if I
do a DoCmd.OpenForm "frmDocument".
I'd appreciate any help.
Zack