Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

duplicate function names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
milkyman@web.de - 30 Jan 2007 12:45 GMT
Hi!

I read that it is not good to overwrite built-in function names in
Access. But as our project used to run with Access97 for a long, long
time, we user defined some util functions and named them as they are
built-in in newer Access versions.

Now we migrated the old project to Access2003 and I would like to
know, which built-in functions are now overwritten, so that we can
delete them and Access can use the built-in functions which should
have a better performance.

Is the any tool or idea, how I can find the overwritten functions?
Searching through over 400 modules seems to be not the best idea. ;-)
Klatuu - 30 Jan 2007 14:01 GMT
Here is a great Find and Replace utility:
http://www.rickworld.com/download.html

You can get an eval copy free, but at $37 US, it is the best dollar for
dollar buy in software (IMHO)
Signature

Dave Hargis, Microsoft Access MVP

> Hi!
>
[quoted text clipped - 10 lines]
> Is the any tool or idea, how I can find the overwritten functions?
> Searching through over 400 modules seems to be not the best idea. ;-)
milkyman@web.de - 30 Jan 2007 14:47 GMT
Thanks for your suggestion, the tool seems to be really nice.

But I don't see the solution to my posting!?!
To use the tool, I need to know the function names. But if I would
know them, I could easily find and delete them.

The point is, that I don't know, which functions are duplicates!

> Here is a great Find and Replace utility:http://www.rickworld.com/download.html
>
[quoted text clipped - 18 lines]
> > Is the any tool or idea, how I can find the overwritten functions?
> > Searching through over 400 modules seems to be not the best idea. ;-)
Klatuu - 30 Jan 2007 15:18 GMT
You would be able to determine that easier than I.  You have the code.
I would use the tool to create a list of all the functions I use in the
application.  If you know which functions were used to replace intrinsic
functions, that would shorten the list.  Then, open VBA Help and do a search
on each of the function names.  If you find the function in Help, you know
that is one you can drop.  If you get no match in Help, the function doesn't
exist in Access.
Signature

Dave Hargis, Microsoft Access MVP

> Thanks for your suggestion, the tool seems to be really nice.
>
[quoted text clipped - 26 lines]
> > > Is the any tool or idea, how I can find the overwritten functions?
> > > Searching through over 400 modules seems to be not the best idea. ;-)
milkyman@web.de - 31 Jan 2007 08:24 GMT
Ok, so a automatic detection of duplicate function names seems to be
impossible?
Then I'll choose someone to go through all the 400 modules and search
for well known function names. Poor guy. ;-)

Anyway thanks for you help and the tool tip.

> You would be able to determine that easier than I.  You have the code.
> I would use the tool to create a list of all the functions I use in the
[quoted text clipped - 37 lines]
> > > > Is the any tool or idea, how I can find the overwritten functions?
> > > > Searching through over 400 modules seems to be not the best idea. ;-)
John Spencer - 31 Jan 2007 12:31 GMT
No, you should not need to search through all 400 modules.

If you have functions that have the same names as VBA functions and want to
remove the functions all you need to know is the location (module) of the
same-named function.  Then you remove the same named function and the VBA
function will get called.

Personnally, I would comment out the function and then compile.  If no error
occurred after the compile, then I would delete the function.

Here is some code that can get you started.  Note that is does NOT search
class modules (forms and reports).  If you use it as is, you will need to
add a table to your database.

'TableName: tbl_ModuleList
'Fields:
'fldDBName - text
'fldModuleName - text
'fldProcName - text
'fldProcCall - text
'fldComments - Memo

'CODE FOLLOWS

Option Compare Database
Option Explicit

Public Function funListModules()
'*******************************************
'Name:      funListModules ()
'Purpose:   Open every module in the current database
'           and list the names of the Functions and Subroutines
'Author:    John Spencer UMBC-CHPDM
'Date:      10/3/2001
'*******************************************

Dim dbs As Database
Dim cntAny As Container
Dim docAny As Document
Dim intCount As Integer

  Set dbs = CurrentDb()
  Set cntAny = dbs.Containers("Modules")

  For intCount = 0 To cntAny.Documents.Count - 1
     Set docAny = cntAny.Documents(intCount)

     'Debug.Print "Module: " & docAny.Name
     If docAny.Name <> "basCrossRef" Then
        funListRoutines docAny.Name
     End If

  Next intCount

  Set docAny = Nothing
  Set cntAny = Nothing
  dbs.Close
  Set dbs = Nothing

End Function

Private Function fAddToTable(strDbName, strModule, strProc, _
                strCall, strComments)
'Adds procedure information to a table using an SQL statement
Dim strSQL As String, strCall1 As String
Dim strComments1 As String

  On Error GoTo fAddtoTable_ERROR

  strCall1 = strCall
  strComments1 = strComments & ""
  strComments1 = ReplaceString(strComments1, Chr(34), Chr(34) & Chr(34)) &
""
  If strComments1 = "" Then strComments1 = "No description"

  strSQL = "INSERT INTO tbl_ModuleList ( fldDBName, fldModuleName," & _
   " fldProcName, fldProcCall, fldComments )" & _
   "Values( " & Chr(34) & strDbName & Chr(34) & _
   ", " & Chr(34) & strModule & Chr(34) & _
   ", " & Chr(34) & strProc & Chr(34) & _
   ", " & Chr(34) & ReplaceString(strCall1, Chr(34), Chr(34) & Chr(34)) & _
   Chr(34) & _
   ", " & Chr(34) & strComments1 & Chr(34) & " )"

  CurrentDb().Execute strSQL, dbFailOnError

  Exit Function

fAddtoTable_ERROR:

  MsgBox "Err# " & Err.Number & ": " & Err.Description, , "fAddToTable"
  Stop

End Function

Private Function funListRoutines(strModule As String)
'Steps through a module and puts the name of its routines into a
'table along with the initial comments in the routine
Dim modAny As Module
Dim tfModuleOpen As Boolean
Dim lngLineCount As Long, lngCurrentLine As Long, lngProcKind As Long
Dim strProcName As String, strOutput As String, strCurrPosition As String
Dim strDbName As String, strCall As String, strComments As String

  strDbName = CurrentDb().Name
  strDbName = Dir(strDbName)

  If IsModuleOpen(strModule) = False Then
     DoCmd.OpenModule strModule
     tfModuleOpen = False
  Else
     tfModuleOpen = True
  End If

  Set modAny = Modules(strModule)

  lngLineCount = modAny.CountOfLines
  lngCurrentLine = 1

  While lngCurrentLine < lngLineCount

     strProcName = modAny.ProcOfLine(lngCurrentLine, lngProcKind)

     If strProcName <> "" Then
        strOutput = strProcName  'modany.Lines(lngCurrentLine, 1)

        While modAny.ProcBodyLine(strProcName, lngProcKind) <>
lngCurrentLine
           lngCurrentLine = lngCurrentLine + 1
           strOutput = strOutput & vbCrLf & _
                    Trim(modAny.Lines(lngCurrentLine, 1))
           strCall = Trim(modAny.Lines(lngCurrentLine, 1))
        Wend

        'Get Call string that is continued
        While Right(strCall, 1) = "_"
           lngCurrentLine = lngCurrentLine + 1
           strCall = Left(strCall, Len(strCall) - 1) & _
                    Trim(modAny.Lines(lngCurrentLine, 1))
        Wend

        lngCurrentLine = lngCurrentLine + 1

        strCurrPosition = Trim(modAny.Lines(lngCurrentLine, 1))

        strComments = ""
        While InStr(1, Trim(strCurrPosition), "'") = 1
           If Trim(ReplaceString(strCurrPosition, "=", "")) = "'" Then
           ElseIf Trim(ReplaceString(strCurrPosition, "*", "")) = "'" Then
           ElseIf Trim(ReplaceString(strCurrPosition, "-", "")) = "'" Then

           Else
              strComments = strComments & Trim(Mid(strCurrPosition, 2)) _
               & vbCrLf
           End If

           strOutput = strOutput & vbCrLf & strCurrPosition
           lngCurrentLine = lngCurrentLine + 1
           strCurrPosition = Trim(modAny.Lines(lngCurrentLine, 1))
        Wend

     End If

     'Output the data
     If Len(strProcName) > 0 Then
        fAddToTable strDbName, strModule, strProcName, _
                   strCall & "", strComments & ""
     End If

     'Step thru lines until we get to a new procedure
     'or we get to the end of the module
     While strProcName = modAny.ProcOfLine(lngCurrentLine, lngProcKind) _
                         And lngCurrentLine < lngLineCount
        lngCurrentLine = lngCurrentLine + 1
     Wend

  Wend

funListRoutines_EXIT:

  Set modAny = Nothing

  If tfModuleOpen = False Then
     DoCmd.Close acModule, strModule, acSaveNo
  End If

  Exit Function

funListRoutines_ERROR:
  Stop

End Function

Private Function IsModuleOpen(strModulename As String) As Boolean
'See if a module is already open
Dim modAny As Module

  On Error GoTo IsModuleOpen_ERROR
  Set modAny = Modules(strModulename)
  IsModuleOpen = True
  Exit Function

IsModuleOpen_ERROR:
  IsModuleOpen = False
End Function

Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Ok, so a automatic detection of duplicate function names seems to be
> impossible?
[quoted text clipped - 52 lines]
>> > > > Searching through over 400 modules seems to be not the best idea.
>> > > > ;-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.