Displaying Code modules

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GulliverUk
    New Member
    • Oct 2007
    • 3

    #1

    Displaying Code modules

    I would like to display the area within a code module where certain text appears.

    The module concerned has numerous lines containing code such as:
    If x Then AddErr 35
    If y then AddErr 45
    etc etc

    The code below works (from a form or other module)

    Dim l1 as long, l2 as long, c1 as long, c2 as long
    Dim bolFound as Boolean
    Dim mdl as module
    DoCmd.OpenModul e "modProcessingB S"
    Set mdl = Modules("modPro cessingBS")
    bolFound = mdl.Find("AddEr r 35", l1, c1, l2, c2, True)
    debug.print bolFound

    Always bolFound is True, but the module display is where it was last opened, not where the line containing "AddErr 35" is to be found. I swear that earlier today Access did exactly this, but no longer. Frustrating. Can anyone help?

    I am using Access 2002 - although I doubt it makes much difference!

    Many thanks to anyone who can help!
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Don't know why you want the module to open at the found line, but why not use the Edit/Find to determine the location ?
    This allows a search per function, module or even all code with a full or partial match of the string....

    Nic;o)

    Comment

    • GulliverUk
      New Member
      • Oct 2007
      • 3

      #3
      Originally posted by nico5038
      Don't know why you want the module to open at the found line, but why not use the Edit/Find to determine the location ?
      This allows a search per function, module or even all code with a full or partial match of the string....

      Nic;o)
      Well, when I view error 35, I want to be able to go straight to the code that generates that error. Why don't I want to use find? Quite simply, it is slow

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Hmm, a slow find is new to me. I've been using it many times and certainly when you have just one module (and set the Find to the "Within Module" scope) I never experienced slow performance.

        I only use the module object for extensive automated updates and your .find is a new approach for me :-)

        Nic;o)

        Comment

        Working...