Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for strings in code???

Status
Not open for further replies.

DaiDreamer

Programmer
May 8, 2001
31
US
Hi!
My boss came up to me with an interesting question. He wants me to find out if it is possible to search though the code looking for certian words (i.e. names of procedures). He also want where the string was found, what is was found it (form module) and the name of the form/procedure in a list box. For example, say there was a procedure name "bob" and I used this program to look for "bob". the result were that "bob" was called in form "sally", module "bill", and report "peter".

Is this possible???

Thanks!

DaiDreamer
 
Look into the Modules Collection. Here's an example from help:

Code:
On Error GoTo Error_LinesInModule
	' Open module.
	DoCmd.OpenModule strModuleName
	' Return reference to Module object.
	Set mdl = Modules(strModuleName)
	' Return number of lines in module.
	LinesInModule = mdl.CountOfLines

The module object of the modules collection has some proerties and methods you might want to use. I.E., ProcBodyLine, CountOfLines, ProcOfLine, Etc.... Tyrone Lumley
augerinn@gte.net
 
Well, that at least is one part. It can get the names of all procedures in the db/app.

To find where they are used would require a bit more - like a complete cross reference. I started one of these long away and far ago (was in Access ver 2.0), and got MOST of the containers done, but never did get to finish the querydefs. You need to get the control source for each control on each form and report, as well as search every line of code in each nodule, form, report and QUERY.

My approach was to build a set of tables for the various containers set up the tables to hold the references to each object within the container type. Once the table were filled in, a few simple queries would easily return the references to the object(s) of interest.

It SOUNDS like a lot of work - and it is - but the actual code involved was not quite as large or complex as it may appear. On the other hand, I wouldn't necessarily advise the 'faint of heart' to go there.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top