[AccessD] JIT Forms?

MartyConnelly martyconnelly at shaw.ca
Sat Sep 4 14:56:20 CDT 2004


You can't recompile code in an mde
But here is some example code to read code in a Form
You can also write code to a form
Have a look at http://www.helenfeddema.com
Design Schemas accarch76.zip  and 77
She modifies existing controls at runtime and adds code.

Function ListAllProcsinForms(strModuleName As String)
'Purpose: lists all procedures/functions for given module
'Example: ListAllProcsinForms ("MyForm")
    Dim mdlF As Form
    Dim mdl As Module
    Dim lngCount As Long, lngCountDecl As Long, lngI As Long
    Dim strProcName As String, astrProcNames() As String
    Dim intI As Integer, strMsg As String
    Dim lngR As Long

    ' Open specified Module object.
    DoCmd.OpenForm strModuleName,acDesign 'open in design view

    ' Return reference to Form object.
     
    Set mdlF = Forms(strModuleName)
    ' Return reference to Module object.
      Set mdl = mdlF.Module
    ' Count lines in module.
 
    lngCount = mdl.CountOfLines
    ' Count lines in Declaration section in module.

    lngCountDecl = mdl.CountOfDeclarationLines
    ' Determine name of first procedure.
    strProcName = mdl.ProcOfLine(lngCountDecl + 1, lngR)
    ' Initialize counter variable.
    intI = 0
    ' Redimension array.
    ReDim Preserve astrProcNames(intI)
    ' Store name of first procedure in array.
    astrProcNames(intI) = strProcName

    ' Determine procedure name for each line after declarations.
    For lngI = lngCountDecl + 1 To lngCount
        ' Compare procedure name with ProcOfLine property value.

        If strProcName <> mdl.ProcOfLine(lngI, lngR) Then
            ' Increment counter.
            intI = intI + 1
            strProcName = mdl.ProcOfLine(lngI, lngR)
            ReDim Preserve astrProcNames(intI)
            ' Assign unique procedure names to array.
            astrProcNames(intI) = strProcName
        End If
    Next lngI

    strMsg = "Procedures in module '" & strModuleName & "': " _
        & vbCrLf & vbCrLf
    Debug.Print "Procedures in module '" & strModuleName & "': "

    For intI = 0 To UBound(astrProcNames)
        strMsg = strMsg & astrProcNames(intI) & vbCrLf
'Print list in debug window:
        Debug.Print astrProcNames(intI)
    Next intI

' Dialog box listing all procedures in module.
    MsgBox strMsg
End Function

Charlotte Foust wrote:

>I've only used it at design time, so I can't say.  I don't suppose it's
>all that different from changing the paper size at run time.
>
>Charlotte Foust
>
>
>-----Original Message-----
>From: John W. Colby [mailto:jwcolby at colbyconsulting.com] 
>Sent: Friday, September 03, 2004 2:13 PM
>To: 'Access Developers discussion and problem solving'
>Subject: RE: [AccessD] JIT Forms?
>
>
>Charlotte,
>
>Do you know if this works at runtime or only at design time?
>
>John W. Colby
>www.ColbyConsulting.com 
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
>Foust
>Sent: Friday, September 03, 2004 4:03 PM
>To: Access Developers discussion and problem solving
>Subject: RE: [AccessD] JIT Forms?
>
>
>Look at the Application.CreateControl method for creating controls from
>code.  If you want code behind that control, you need to add that to the
>form's module and set the control's named event to "[event procedure]"
>to connect them.
>
>Charlotte Foust
>
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list