By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,948 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,948 IT Pros & Developers. It's quick & easy.

Find a string in all the code using a function

P: n/a
Dear All,

I'm looking for a function that does the same as the find-action in the
code-window.

Thanks,

Filip
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
look up the InStr() function....
"Filips Benoit" <be***********@pandora.be> wrote in message
news:R%***********************@phobos.telenet-ops.be...
Dear All,

I'm looking for a function that does the same as the find-action in the
code-window.

Thanks,

Filip

Nov 13 '05 #2

P: n/a
Yes but how to loop all code of all forms, modules and report

filip

"miTchell" <mitchell@"no_spam".topsideinc.com> wrote in message
news:1097170773.mi5x0iHyhXbakayNlVJSgw@teranews...
look up the InStr() function....
"Filips Benoit" <be***********@pandora.be> wrote in message
news:R%***********************@phobos.telenet-ops.be...
Dear All,

I'm looking for a function that does the same as the find-action in the
code-window.

Thanks,

Filip


Nov 13 '05 #3

P: n/a
Filips Benoit wrote:
Dear All,

I'm looking for a function that does the same as the find-action in the
code-window.

Thanks,

Filip


Look at the Find method for the Module object in help. Also, look at
the code example for the Find method.
Nov 13 '05 #4

P: n/a
Here is an incomplete bit of code that I am working on, nicked from
somewhere

Function GetModuleInfo(ObjName As String, SearchStg As String) As Boolean

Dim Mdl As Module
Dim lngSLine As Long, lngSCol As Long
Dim lngELine As Long, lngECol As Long, lngENameCol As Long
Dim strLine As String
Dim ObjectName As String
Dim ObjectTypeID As Long

' Return reference to Module object.
DoCmd.OpenModule (ObjName)
' Search for string.

Set Mdl = Modules(ObjName)
NextMLine:

While lngSLine < Mdl.CountOfLines
' Still this module
lngSLine = LastLine
If Mdl.Find(SearchStg, lngSLine, lngSCol, lngELine, lngECol) Then
' Found
'..... Do something
end if
Wend

HTH
Phil

"Filips Benoit" <be***********@pandora.be> wrote in message
news:vd***********************@phobos.telenet-ops.be...
Yes but how to loop all code of all forms, modules and report

filip

"miTchell" <mitchell@"no_spam".topsideinc.com> wrote in message
news:1097170773.mi5x0iHyhXbakayNlVJSgw@teranews...
look up the InStr() function....
"Filips Benoit" <be***********@pandora.be> wrote in message
news:R%***********************@phobos.telenet-ops.be...
> Dear All,
>
> I'm looking for a function that does the same as the find-action in the
> code-window.
>
> Thanks,
>
> Filip
>
>



Nov 13 '05 #5

P: n/a
Thanks All,

This is my result
************************************************** ************************
Public Function SearchProjectModulesCode(ByVal strFindString As String) As
String

On Error GoTo errHandling

Dim MyObject As Object
Dim MyMdl As Module
Dim iLoop, iObjectCount, iFound As Long
Dim strSearchString As String
SearchProjectModulesCode = "String '" & strFindString & "' found in
modules:" & Chr(13)

For Each MyObject In CurrentProject.AllModules
If FindInCode(MyObject.Name, strFindString) Then
SearchProjectModulesCode = SearchProjectModulesCode & Chr(13) & ">" &
MyObject.Name
iObjectCount = iObjectCount + 1
Next MyObject
SearchProjectModulesCode = SearchProjectModulesCode & Chr(13) & Chr(13) &
iObjectCount & " modules cheked!"

Exit Function

errHandling:
MsgBox Err.Number & " " & Err.Description
End Function

Function FindInCode(strModuleName As String, strSearchText As String) As
Boolean
Dim mdl As Module
Dim lngSLine As Long, lngSCol As Long
Dim lngELine As Long, lngECol As Long
Dim strLine As String, strNewLine As String
Dim intChr As Integer, intBefore As Integer, _
intAfter As Integer
Dim strLeft As String, strRight As String

Set mdl = Modules(strModuleName)

If mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol) Then
FindInCode = True
Else
FindInCode = False
End If

Exit_FindAndReplace:
Exit Function

Error_FindAndReplace:

MsgBox Err & ": " & Err.Description
FindInCode = False
Resume Exit_FindAndReplace
End Function
************************************************** **********************

"Salad" <oi*@vinegar.com> wrote in message
news:_j*****************@newsread3.news.pas.earthl ink.net...
Filips Benoit wrote:
Dear All,

I'm looking for a function that does the same as the find-action in the
code-window.

Thanks,

Filip


Look at the Find method for the Module object in help. Also, look at
the code example for the Find method.

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.