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.

How to rename Modules ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
javiernews - 21 Jan 2007 15:19 GMT
Hi

I'm using the following code to rename all Modules, the code is working good,
but I have
but I have to execute several times to change (re-name) all modules names.

How to re-name all modules clicking 1 time only ?

Private Sub Command0_Click()
On Error Resume Next

Const cPrefix As String = "mod_"
Dim obj As AccessObject
Dim dbs As Object
Dim strNewModule As String
Dim lngi As Long
Dim lngLong As Byte

   Set dbs = Application.CurrentProject
   lngi = 11
   
   
   lngLong = Len(cPrefix)

   For Each obj In dbs.AllModules
   
           If left(obj.Name, lngLong) <> cPrefix Then
Start_2:
                   strNewModule = cPrefix & lngi
                   lngi = lngi + 1
                   
                   If funExisteModulo(strNewModule) = False Then
                       DoCmd.Rename strNewModule, acModule, obj.Name '<< Old
Module name
                   Else
                       GoTo Start_2
                   End If
           End If
   Next obj
   
   
   Set dbs = Nothing
   Set obj = Nothing

   MsgBox "The end"

End Sub

Private Function funExisteModulo(Module_Name As String) As Boolean

Dim obj As AccessObject
Dim dbs As Object

   funExisteModulo = False
   Set dbs = Application.CurrentProject
   For Each obj In dbs.AllModules
       If obj.Name = Module_Name Then
           funExisteModulo = True
           Exit For
       End If
   Next obj
       
Close_Function:
   Set dbs = Nothing
   Set obj = Nothing

End Function

Bye & thank you in advance
John Spencer - 21 Jan 2007 17:27 GMT
Try changing the code so you loop through in reverse order of the objects.

For ICount = Dbs.AllModules.Count -1 to 0
 set Obj = DbsAllModules.Obj(iCount)

... process here ---

Next ICount

> Hi
>
[quoted text clipped - 65 lines]
>
> Bye & thank you in advance
javiernews - 21 Jan 2007 19:01 GMT
Thanks John but is Not working,
even now is Not re-namimg any Module.

bye & thank you !
 
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.