referring to a form instance in front-end database

Posted on 2010-01-01
Last Modified: 2013-11-28
I am using a collection to manage form instances in my front-end database, such as this:

Function fOpenFormInstance(strForm As String)
    On Error GoTo Err_event
    Dim frm As Form
    Select Case strForm
        Case "frmEntityMgmt"
            Set frm = New Form_frmEntityMgmt
            clnForms.Add Item:=frm, Key:=CStr(frm.Hwnd)
            frm.Tag = frm.Hwnd
      End Select
    frm.Visible = True
    Set frm = Nothing
    Exit Function
    MsgBox Err.Description
    GoTo Exit_Event
End Function

I then have several different functions that I use, and refer to the active form in this manner:

Public Function fLoadEntityMgmtSubforms(strFormID As String)
    Set frmCurrent = clnForms(strFormID)
    If frmCurrent.Controls("ctlName").value = ""....

If I want to create a library db to store a lot of my functions in, how would I refer to the instance of the form in my front-end database?  (in the above example obviously the forms collection and function are in the same database)
Question by:MsSherry
    LVL 84
    I'm not sure you can, although you may be able to contrive some form of interaction between the two.

    You would be far better served placing code like this in a standard module, and just importing that module to all new databases you build.

    Author Comment

    Thanks LSM and sorry about the late response... Cable went out as well as my internet service!  Thanks for your suggestion.  I'll keep question opened for another day, and then reward you the points if I get no solution, but I think you may be right.
    LVL 84

    Accepted Solution

    Working with Object instances via referenced modules (i.e. your standard library database) is not the best way, in my opinion. In my opinion, those library database should be used for code routines that don't really have to interact directly with running objects. You could perhaps alter your routines such that you would pass INTO that routine a form or report object, then your code could act upon that object. That said, I'm not sure a referenced database could do that.

    It seems that most Access developers use the "import the module" routine for these sorts of things, but there are several out there using the referenced databases for code repositories.

    Good luck in whatever method you choose!

    Author Closing Comment

    Thanks LSM.  Sometimes I tend to over-complicate things in an attempt to simplify things ... :)  I have used your suggestion and narrowed down the modules I am storing in the library database.

    Thanks again

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now