[AccessD] Multi-Instance Forms re-visited

Francisco Tapia fhtapia at gmail.com
Wed Dec 15 15:02:57 CST 2004


Jim that sounds great (re: more code :D),

I was wondering on this line:

m_col.add(x,hWnd)

access complains about an '='
so I re-wrote it as m_col.add x, hWnd


On Wed, 15 Dec 2004 15:40:05 -0500, Jim DeMarco
<Jdemarco at hudsonhealthplan.org> wrote:
> Francisco,
> 
> What about writing the value you want to use as openargs to an xml file and reading it in after the form is open?
> 
> Or instead of a standard collection use a custom collection class that is similar to the one you have here but it would hold the form refernce, the form's hwind, and the openarg value.
> 
> First a class to hold the data you're trying to use:
> 
> 'MyClass
> <classStub>
> Public Property Let Form(frm as Access.Form)...
> Public Property Let hWnd(hWnd as String)...
> Public Property Let OpenArgs(Args As String)...
> </classStub>
> 
> <collectionclassmodule>
> dim m_col as Collection
> 
> 'MyCollectionClass
> Sub Add(frm As Access.Form, hWnd as String, OpenArgs as String, Optional Key As Variant)
> dim x as MyClass
> Sex x = new MyClass
>         x.Form = frm
>         x.hWnd = hWnd
>         x.OpenArgs = OpenArgs
>         m_col.add(x,hWnd)
> End Sub
> 
> Function Item(index As Variant) As MyClass
>     Set Item = m_col.Item(index)
> End Function
> </collectionclassmodule>
> 
> Now you've got access in your collection to all the info you need for your form.
> To store the values
> <snip>
> Dim MyCol as MyCollectionClass
> 
>         MyCol.Add(frm, frm.Hwnd, "value1;value2))
> </snip>
> 
> To retrieve them:
> <snip>
> Dim MyStringArg As String
>         MyStringArg = MyCol.Item(frm.hwnd).OpenArgs
>         'do something with MyStringArg
> 
> </snip>
> 
> It's really not as complicated as it might look. If you need more info or my complete custom collection class stub (VB) let me know.
> 
> HTH,
> 
> Jim DeMarco
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Francisco
> Tapia
> Sent: Wednesday, December 15, 2004 1:40 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] Multi-Instance Forms re-visited
> 
> So I have the following code in a public module..
> 
> the purpose is to have more than one instance of the form where end
> users can start "multiple calls" and then keep starting newer calls.
> 
> the following code works really well and in fact I can do what I need
> with it, except passing openargs... I figure I can use a workaround
> unless someone here knows of a better way?
> 
> thanks,
> 
> ---CODE SNIP------------
> Option Compare Database
> Option Explicit
> 'Author:    Allen J Browne, January 2000
> 'Email:     abrowne at odyssey.apana.org.au
> 
> Public clnClient As New Collection  'Instances of frmClient.
> 
> Function OpenAClient()
>     'Purpose:   Open an independent instance of form frmClient.
>     Dim frm As Form
> 
>     'Open a new instance, show it, and set a caption.
>     Set frm = New Form_frmClient
>     frm.Visible = True
>     frm.Caption = frm.Hwnd & ", opened " & Now()
> 
>     'Append it to our collection.
>     clnClient.Add Item:=frm, Key:=CStr(frm.Hwnd)
>     Set frm = Nothing
> End Function
> 
> Function CloseAllClients()
>     'Purpose: Close all instances in the clnClient collection.
>     'Note: Leaves the copy opened directly from database window.
>     Dim lngKt As Long
>     Dim lngI As Long
> 
>     lngKt = clnClient.Count
>     For lngI = 1 To lngKt
>         clnClient.Remove 1
>     Next
> End Function
> ---END CODE SNIP-----------------
-- 
-Francisco
http://pcthis.blogspot.com | PC news with out the jargon!



More information about the AccessD mailing list