>>Form's code

  • Thread starter Thread starter Jonathan
  • Start date Start date
J

Jonathan

Hi I would like to create a routine that will search a form's code to check
whether a function call exists on this form.

Is there a way to do this?

Many thanks,

Jonathan
 
Jonathan said:
Hi I would like to create a routine that will search a form's code to check
whether a function call exists on this form.


It's possible, but why bother when you can just use the Edit
- Find menu item?
 
Hi Marshall,

yes your right about using the built-in functions. However I would like to
search a large number of forms and feel that doing this programmatically is
more efficient.

Jonathan
 
The Find menu has an option to search the entire project,
but that includes all reports and module objects.

If you really need to create a procedure that you can run
from the Immediate window, then the code could would be
along these lines of this air code:

Dim db As DAO.Database
Dim doc As DAO.Document
Dim mdl As Module
Dim StartLine As Long, EndLine As Long
Dim StartCol As Long, EndCol As Long

Set db = CurrentDb()
For Each doc In db.Containers!Forms.Documents
DoCmd.OpenForm doc.Name, acDesign
If Forms(doc.Name).HasModule Then
Set mdl = Forms(doc.Name).Module
StartLine = 0
Do
StartCol = 0
EndLine = mdl.CountOfLines
EndCol =9999
StartLine = StartLine + 1
If mdl.Find "nameoffuntion", StartLine, StartCol, _
EndLine, EndCol, _
WholeWord:= True _
Then
Debug.Print doc.Name, mdl.ProcOfLine(StartLine)
Debug.Print spc(5); mdl.Lines(StartLinem1)
Else
Exit Do
End If
Loop While True
DoCmd.Close acForm, doc.Name, acSaveNo
End If
Next doc
 
Hi Marshall, thanks very much.

Jonathan

Marshall Barton said:
The Find menu has an option to search the entire project,
but that includes all reports and module objects.

If you really need to create a procedure that you can run
from the Immediate window, then the code could would be
along these lines of this air code:

Dim db As DAO.Database
Dim doc As DAO.Document
Dim mdl As Module
Dim StartLine As Long, EndLine As Long
Dim StartCol As Long, EndCol As Long

Set db = CurrentDb()
For Each doc In db.Containers!Forms.Documents
DoCmd.OpenForm doc.Name, acDesign
If Forms(doc.Name).HasModule Then
Set mdl = Forms(doc.Name).Module
StartLine = 0
Do
StartCol = 0
EndLine = mdl.CountOfLines
EndCol =9999
StartLine = StartLine + 1
If mdl.Find "nameoffuntion", StartLine, StartCol, _
EndLine, EndCol, _
WholeWord:= True _
Then
Debug.Print doc.Name, mdl.ProcOfLine(StartLine)
Debug.Print spc(5); mdl.Lines(StartLinem1)
Else
Exit Do
End If
Loop While True
DoCmd.Close acForm, doc.Name, acSaveNo
End If
Next doc
--
Marsh
MVP [MS Access]

yes your right about using the built-in functions. However I would like to
search a large number of forms and feel that doing this programmatically is
more efficient.
 
Back
Top