>>Form's code

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
 
M

Marshall Barton

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?
 
J

Jonathan

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
 
M

Marshall Barton

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
 
J

Jonathan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top