473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to 'dump' all standard and class module code lines into an Access table

MLH
In this forum, under a different subject title, I have explored the
following: I want to examine each procedure in my class modules
and standard modules (A97)

Since the other subject title was substantially different from this
objective, I have posted my topic as a new thread more appropriately
titled.

Question:
Can someone tell me how I can DUMP all my standard and class
modules into an Access table for standard text based observation
and study?
Nov 13 '05 #1
15 2340
MLH <CR**@NorthState.net> wrote:

Question:
Can someone tell me how I can DUMP all my standard and class
modules into an Access table for standard text based observation
and study?


The following dump to files. Observe that the all Forms should be able
be opened alone (not be dependt on presentes of other opended forms
and not dependt on opening with special arguments/condition)

Function writeModulesText()
Dim dbs As Database, ctr As Container, modNames As New Collection
Dim i%, mName$, dbloc$, fileN$, archivename$, filelist$
Set dbs = CurrentDb()
dbloc = parentFolder(dbs.Name)
Set ctr = dbs.Containers!Modules
For i = 0 To ctr.Documents.Count - 1
mName = ctr.Documents(i).Name
saveCodeFile acModule, mName, dbloc, IIf(isUpper(mName),
".cls", ".bas"), 1: Next
Set ctr = dbs.Containers!Forms
For i = 0 To ctr.Documents.Count - 1
mName = ctr.Documents(i).Name
DoCmd.OpenForm mName, , , , , acHidden, codebackup
If Forms.Item(mName).HasModule Then
saveCodeFile acForm, mName, dbloc, ".cls", 1
End If
DoCmd.Close acForm, mName: Next
End Function

Sub saveCodeFile(asObject As AcObjectType, objName$, locSl$, ext$,
fileRangenumber%)
Dim fileN$
fileN = locSl & objName & ext
SaveAsText asObject, objName, fileN
End Sub

Function parentFolder$(path, Optional sepC$ = "\")
Dim bslpos
bslpos = InStrRev(path, sepC)
If bslpos = Len(path) Then
bslpos = InStrRev(path, sepC, bslpos - 1): End If
path = Left(path, bslpos)
parentFolder = path
End Function

Function isUpper(test$) As Boolean
isUpper = Asc(test) - Asc(LCase(test))
End Function
--
Regards
Benny Andersen
Nov 13 '05 #2
....
forgot to mention the code is access 2000 runable.
--
Mvh Benny Andersen
Nov 13 '05 #3
MLH
I didn't see anything in it that jumped right out as
likely a problem in A97. Will give it a try. You know
of any associated gotcha that may surprise me in
an A97 environment?
Nov 13 '05 #4
MLH
Well, A97 did give me this error...
"Automation type not supported in Visual Basic"
when compiling in A97 module. Here is the offending line...

Sub saveCodeFile(asObject As AcObjectType, objName$, locSl$, ext$,
fileRangenumber%)

Then, it also barfed on this a bit, saying "Variable not defined"...

DoCmd.OpenForm mName, , , , , acHidden, codebackup

.... it didn't like 'codebackup' at all

Anything I can do about those two lines to make them more A97
compatible?
Nov 13 '05 #5
On Sun, 31 Jul 2005 02:05:39 -0400, MLH <CR**@NorthState.net> wrote:
Well, A97 did give me this error...
"Automation type not supported in Visual Basic"
when compiling in A97 module. Here is the offending line...

Sub saveCodeFile(asObject As AcObjectType, objName$, locSl$, ext$,
fileRangenumber%) AcObjectType is the argument type of the first argument to
'saveAsText'. In access 2000 it belongs to the 'Microsoft Acces 9.0
object library'. You must try to find out which datatype 'saveAsText'
expexts at your ssystem.
Then, it also barfed on this a bit, saying "Variable not defined"...

DoCmd.OpenForm mName, , , , , acHidden, codebackup


Sorry - i forgot to send a top line from my module:

Public Const codebackup = "codebackupStr"

But! the need for that is specific for my system. Just remove the last
argument 'codebackup' from the docmd..... line.
The explanation is:
The argument is what apears as me.openargs in forms. I use that to
make some forms behave different when opened for code backup.
It is a codewritting style not to use a string direct - to relife me
of the burden to spell that correct in the forms.

--
Regards
Benny Andersen
Nov 13 '05 #6
MLH
Benny, is the SaveAsText command an Access 2000
specific command? If so, does it attempt to save as a
text file or to a table?
Nov 13 '05 #7
MLH
It appears to me that this code saves text of modules to a disk file.
That is useful, and I could do that, I suppose. What I really wanted
to do, however, was write each line of code to a record in an Access
table directly. Can you modify your code here to do that?
Nov 13 '05 #8
Can the USysPatch module on my site help you? Section Code Modules. (I
may have posted this answer before but it doesn't show up). Call routine
gatherSigs(), after you've either created the tables it needs, or set
them up with createSigsTables()

MLH wrote:
It appears to me that this code saves text of modules to a disk file.
That is useful, and I could do that, I suppose. What I really wanted
to do, however, was write each line of code to a record in an Access
table directly. Can you modify your code here to do that?


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Nov 13 '05 #9
MLH
Thx for the hint. I cut 'n pasted the code into a standard
module. The only thing that showed up in RED was at the
top of the code...

Attribute VB_Name = "USysPatch"

I rem'd it out because I didn't understand what it was supposed
to be doing. When I compiled the module, I got a compile-time
error in Function execFQT complaining the tWips had not been
initialized. So I dim'd it As Long. That eliminated the error. But
another surfaced in the same procedure complaining that vbEvent
had not been initialized. Should I dim that one As Variant? I'm
going to just to get by the error. That got me by. Then, one popped
up in Sub RemoveFalseHits() complaining that er94InvalidUseOfNull
had not been initialized. I'm dimming that As Integer, OK?

Well, I made it out-a-the compile-time errors. Now, for trying it out.
What, exactly, is it supposed to do?
Nov 13 '05 #10
Shh, I will learn to produce valid components. One day.

public const tWips=567'amount of twips in a centimeter
public const vbEvent="[Event Procedure]"
' you could remove the procedure execFQT since it only
' functions as a code example, and then you don't need
' vbEvent in this module anymore.
public const er94InvalidUseOfNull=94

After you call createSigsTables, two new tables are made in your mdb.
One will hold all procedure code, one is to store information about
which routine calls which one.

gatherSigs does the collecting job. It puts all code from standard
modules and forms into the table. It also does the calling bit.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Nov 13 '05 #11
On Sun, 31 Jul 2005 12:10:48 -0400, MLH <CR**@NorthState.net> wrote:
Benny, is the SaveAsText command an Access 2000
specific command? If so, does it attempt to save as a
text file or to a table?

Using F2 in my vba editor

Sub SaveAsText(ObjectType As AcObjectType, ObjectName As String,
FileName As String) Member of Access.Application ( Microsoft Access
9.0 Object Library)
( it was hidden)

I would belive that 'Microsoft Access 9.0 Object Library' is
distribuated with access2000 and perhaps later wersions, but you can
try to look in tools->references if you have it.

--
Regards
Benny Andersen
Nov 13 '05 #12
On Sun, 31 Jul 2005 12:16:18 -0400, MLH <CR**@NorthState.net> wrote:
It appears to me that this code saves text of modules to a disk file.
That is useful, and I could do that, I suppose. What I really wanted
to do, however, was write each line of code to a record in an Access
table directly. Can you modify your code here to do that?


This is examples of text output , but again, not testet in access97

<vba_access_2000>
Sub printModuleLines(moduleName$)
Debug.Print Modules.Item(moduleName).Lines(1,
Modules.Item(moduleName).CountOfLines)
End Sub

Sub printFormCodeLines(formName$)
DoCmd.OpenForm formName
If Forms.Item(formName).HasModule Then
Debug.Print Forms.Item(formName).Module.Lines(1,
Forms.Item(formName).Module.CountOfLines)
End If
DoCmd.Close acForm, formName
End Sub
</vba_access_2000>
--
Regards
Benny Andersen
Nov 13 '05 #13
On Mon, 01 Aug 2005 13:29:25 +0200, Benny Andersen <do**@mail.me>
wrote:
On Sun, 31 Jul 2005 12:10:48 -0400, MLH <CR**@NorthState.net> wrote:
Benny, is the SaveAsText command an Access 2000
specific command? If so, does it attempt to save as a
text file or to a table?Using F2 in my vba editor

Sub SaveAsText(ObjectType As AcObjectType, ObjectName As String,
FileName As String) Member of Access.Application ( Microsoft Access
9.0 Object Library)
( it was hidden)
I would belive that 'Microsoft Access 9.0 Object Library' is
distribuated with access2000 and perhaps later wersions, but you can
try to look in tools->references if you have it.


SaveAsText (and it's inverse operation LoadFromText), are available in
all versions of Access >= 97. Both are "hidden" in all versions.
--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #14
MLH
Procedures in Hidden Module, I assume?

That's the first I've heard of that. I don't have to do anything
special to use them - just because they are hidden, that is?

Just call 'em as if they were built-in commands, right?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx

SaveAsText (and it's inverse operation LoadFromText), are available in
all versions of Access >= 97. Both are "hidden" in all versions.


Nov 13 '05 #15
MLH
Alright! I can't wait to try it. Sounds exactly like what I need.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Shh, I will learn to produce valid components. One day.

public const tWips=567'amount of twips in a centimeter
public const vbEvent="[Event Procedure]"
' you could remove the procedure execFQT since it only
' functions as a code example, and then you don't need
' vbEvent in this module anymore.
public const er94InvalidUseOfNull=94

After you call createSigsTables, two new tables are made in your mdb.
One will hold all procedure code, one is to store information about
which routine calls which one.

gatherSigs does the collecting job. It puts all code from standard
modules and forms into the table. It also does the calling bit.


Nov 13 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
3
by: Chris Stiles | last post by:
Is there a human readable dump format for objects ? As opposed to pickling ? It doesn't necessarily have to be XML - in fact i'd prefer if it wasn't ;) - but ISTR an XML dump library. --...
8
by: Raymond Hettinger | last post by:
Comments are invited on the following proposed PEP. Raymond Hettinger ------------------------------------------------------- PEP: 329
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
5
by: randomblink | last post by:
Alright... Does anyone know if you can create a class that has a constructor? I would like to create a BUTTONMANAGER class that handles my buttons for me... I am doing this in Access for those...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
9
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug...
8
by: Joel Reinford | last post by:
I would like to build a class that has properties which can be accessed by string names or index numbers in the form of MyClass.Item("LastName"). The string names or item index values would be...
4
by: Aidan | last post by:
Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.