In VBA an Access module has a find method - works perfectly to find a string inside a module. i'm working in A97 (legacy) systems (large ones) and want to write code that searches all modules so that I can check on the possible effects of a change. But the 97 modules collection is open modules only.
Access 97 doesn't have an allmodules collection - 2000+ does - so I can move the app up for this purpose. But now I find that a module in allmodules is an 'access object' and doesn't respond to the module.find method.
Any ideas? thanks
Peter Hall
3 5829
In VBA an Access module has a find method - works perfectly to find a string inside a module. i'm working in A97 (legacy) systems (large ones) and want to write code that searches all modules so that I can check on the possible effects of a change. But the 97 modules collection is open modules only.
Access 97 doesn't have an allmodules collection - 2000+ does - so I can move the app up for this purpose. But now I find that a module in allmodules is an 'access object' and doesn't respond to the module.find method.
Any ideas? thanks
Peter Hall
Hi Pete,
I have two...that may or may not work with 97. I apologise if not, as I have no way to test them.
The first is a Joe Kendal module. The second is home grown for a specific purpose, but shows a loop through the Modules Container object. -
Option Compare Database
-
-
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
'Function to Search for a String in a Code Module. It will return True if it is found and
-
'False if it is not. It has an optional parameter (NewString) that will allow you to
-
'replace the found text with the NewString. If NewString is not included in the call
-
'to the function, the function will only find the string not replace it.
-
'
-
'Created by Joe Kendall 02/07/2003
-
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-
Public Function SearchOrReplace(ByVal ModuleName As String, ByVal StringToFind As String, _
-
Optional ByVal NewString, Optional ByVal FindWholeWord = False, _
-
Optional ByVal MatchCase = False, Optional ByVal PatternSearch = False) As Boolean
-
-
Dim mdl As Module
-
Dim lSLine As Long
-
Dim lELine As Long
-
Dim lSCol As Long
-
Dim lECol As Long
-
Dim sLine As String
-
Dim lLineLen As Long
-
Dim lBefore As Long
-
Dim lAfter As Long
-
Dim sLeft As String
-
Dim sRight As String
-
Dim sNewLine As String
-
-
Set mdl = Modules(ModuleName)
-
-
If mdl.Find(StringToFind, lSLine, lSCol, lELine, lECol, FindWholeWord, _
-
MatchCase, PatternSearch) = True Then
-
If IsMissing(NewString) = False Then
-
' Store text of line containing string.
-
sLine = mdl.Lines(lSLine, Abs(lELine - lSLine) + 1)
-
' Determine length of line.
-
lLineLen = Len(sLine)
-
' Determine number of characters preceding search text.
-
lBefore = lSCol - 1
-
' Determine number of characters following search text.
-
lAfter = lLineLen - CInt(lECol - 1)
-
' Store characters to left of search text.
-
sLeft = Left$(sLine, lBefore)
-
' Store characters to right of search text.
-
sRight = Right$(sLine, lAfter)
-
' Construct string with replacement text.
-
sNewLine = sLeft & NewString & sRight
-
' Replace original line.
-
mdl.ReplaceLine lSLine, sNewLine
-
End If
-
SearchOrReplace = True
-
Else
-
SearchOrReplace = False
-
End If
-
-
Set mdl = Nothing
-
End Function
-
-
Public Sub tryme()
-
Dim DB As DAO.DataBase
-
Dim ctr As Container
-
Dim doc As Document
-
Dim amod As Module
-
-
On Error Resume Next
-
-
Set DB = CurrentDb
-
' Set Container object variable.
-
Set ctr = DB.Containers("Modules")
-
For Each modu In ctr
-
' doc.Properties.Refresh
-
' If doc.Name <> "MSys*" And doc.Name <> "~*" Then
-
' DoCmd.OpenForm doc.Name, acDesign
-
' If Forms(doc.Name).HasModule = True Then
-
' DoCmd.OpenModule "Form_" & doc.Name
-
' Debug.Print SearchOrReplace("Mod_" & modu.Name, "testing")
-
' End If
-
' DoCmd.Close acForm, doc.Name
-
' End If
-
Next
-
-
Set ctr = Nothing
-
DB.Close
-
Set DB = Nothing
-
Set doc = Nothing
-
End Sub
-
-
I'll keep looking around to see if I hve another.
J
Hi, thanks for this, the second part of the code trying the container is interesting and I'll try it asap today and tell youi how it goes, thanks again for taking the time to look for this
Peter
Hi Pete,
I have two...that may or may not work with 97. I apologise if not, as I have no way to test them.
The first is a Joe Kendal module. The second is home grown for a specific purpose, but shows a loop through the Modules Container object. -
Option Compare Database
-
-
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
'Function to Search for a String in a Code Module. It will return True if it is found and
-
'False if it is not. It has an optional parameter (NewString) that will allow you to
-
'replace the found text with the NewString. If NewString is not included in the call
-
'to the function, the function will only find the string not replace it.
-
'
-
'Created by Joe Kendall 02/07/2003
-
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-
Public Function SearchOrReplace(ByVal ModuleName As String, ByVal StringToFind As String, _
-
Optional ByVal NewString, Optional ByVal FindWholeWord = False, _
-
Optional ByVal MatchCase = False, Optional ByVal PatternSearch = False) As Boolean
-
-
Dim mdl As Module
-
Dim lSLine As Long
-
Dim lELine As Long
-
Dim lSCol As Long
-
Dim lECol As Long
-
Dim sLine As String
-
Dim lLineLen As Long
-
Dim lBefore As Long
-
Dim lAfter As Long
-
Dim sLeft As String
-
Dim sRight As String
-
Dim sNewLine As String
-
-
Set mdl = Modules(ModuleName)
-
-
If mdl.Find(StringToFind, lSLine, lSCol, lELine, lECol, FindWholeWord, _
-
MatchCase, PatternSearch) = True Then
-
If IsMissing(NewString) = False Then
-
' Store text of line containing string.
-
sLine = mdl.Lines(lSLine, Abs(lELine - lSLine) + 1)
-
' Determine length of line.
-
lLineLen = Len(sLine)
-
' Determine number of characters preceding search text.
-
lBefore = lSCol - 1
-
' Determine number of characters following search text.
-
lAfter = lLineLen - CInt(lECol - 1)
-
' Store characters to left of search text.
-
sLeft = Left$(sLine, lBefore)
-
' Store characters to right of search text.
-
sRight = Right$(sLine, lAfter)
-
' Construct string with replacement text.
-
sNewLine = sLeft & NewString & sRight
-
' Replace original line.
-
mdl.ReplaceLine lSLine, sNewLine
-
End If
-
SearchOrReplace = True
-
Else
-
SearchOrReplace = False
-
End If
-
-
Set mdl = Nothing
-
End Function
-
-
Public Sub tryme()
-
Dim DB As DAO.DataBase
-
Dim ctr As Container
-
Dim doc As Document
-
Dim amod As Module
-
-
On Error Resume Next
-
-
Set DB = CurrentDb
-
' Set Container object variable.
-
Set ctr = DB.Containers("Modules")
-
For Each modu In ctr
-
' doc.Properties.Refresh
-
' If doc.Name <> "MSys*" And doc.Name <> "~*" Then
-
' DoCmd.OpenForm doc.Name, acDesign
-
' If Forms(doc.Name).HasModule = True Then
-
' DoCmd.OpenModule "Form_" & doc.Name
-
' Debug.Print SearchOrReplace("Mod_" & modu.Name, "testing")
-
' End If
-
' DoCmd.Close acForm, doc.Name
-
' End If
-
Next
-
-
Set ctr = Nothing
-
DB.Close
-
Set DB = Nothing
-
Set doc = Nothing
-
End Sub
-
-
I'll keep looking around to see if I hve another.
J
Hi J, thanks for this, the second part of the code trying the container is interesting and I'll try it asap today and tell youi how it goes, thanks again for taking the time to look for this
Peter
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rufus |
last post by:
Hi,
On the project I am working on we need to encapsulate all data and business
logic in an activex dll. My question is: How do I do this? How can I
access the form objects ie text boxes, buttons with a dll?
Thanks.
|
by: AnandaSim |
last post by:
I just had a google through this NG but have not seen mention of Erik
Rucker's blog entry and the new Jet:
http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx
mentioned by Mike Gunderloy
http://www.larkware.com/dg4/TheDailyGrind726.html
Aside from the Sharepoint feature extension, amazing news.
|
by: jqpdev |
last post by:
Hello all...
I'm coming from a Borland Delphi background. Delphi has a specific
component called a Data Module. In the designer the Data Module behaves
like a windows form. A developer can drop non-visual (controls) on the data
module surface and wire them up and create procedures, functions, event
procedures. In the source file (code behind file) the Data Module is a
class, and the dropped components are public properties. The...
|
by: Robin Haswell |
last post by:
Hey people
I'm an experience PHP programmer who's been writing python for a couple of
weeks now. I'm writing quite a large application which I've decided to
break down in to lots of modules (replacement for PHP's include()
statement).
My problem is, in PHP if you open a database connection it's always in
scope for the duration of the script. Even if you use an abstraction layer
($db = DB::connect(...)) you can `global $db` and bring...
|
by: nandar |
last post by:
Hi All,
I am involved in migratinig one of the MS Access Project to ASP.Net and SQL Server 2000. My question here is that how Modules and Class Modules can be taken care in ASP.Net. To some extend I know the answer but I want to know whether that is the right way or any other solution is available.
My understanding is,
1) MS Access Modules will be placed in the App_code directory (wrt .Net 2.0) and set the Methods and the variables to...
| |
by: nandar |
last post by:
Hi All,
I am involved in migratinig one of the MS Access Project to ASP.Net and SQL Server 2000. My question here is that how Modules and Class Modules (MS Access) can be taken care in ASP.Net. To some extend I know the answer (I beleive) but I want to know whether that is the right way or any other solution is available.
My understanding is,
1) MS Access Modules will be placed in the App_code directory (wrt .Net 2.0) and set the Methods...
|
by: Lysander |
last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access Security, but I'll start with something short and simple
This code was written in Access 2003 but should be valid in Access 2000
By default, when you start a new module, either in a form or report, or a global module, Access does not declare Option...
|
by: Roy Tong |
last post by:
I maintain a shared database on Access 97. I've just tried converting
a test copy of the database to 2003 and it appeared to work OK. That
is I got no error messages. However then I look at my modules, only 2
out of 9 have copied across.
Do I need to do something special to recompile modules and take them
across to the new version? I thought the conversion process would just
handle it. Well it seems to for 2 of the 9 and I got no...
|
by: howard.canaway |
last post by:
I have always wondered about the specification page in the Access Help
files. It reads
Microsoft Access database (.mdb) file size 2 gigabytes. However,
because your database can include linked tables in other files, its
total size is limited only by available storage capacity.
Number of objects in a database 32,768
Modules (including forms and reports with the HasModule property set
to True) 1,000
Number of characters in an object name...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |