J
javiernews via AccessMonster.com
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
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