By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
15 Replies


P: n/a
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

P: n/a
....
forgot to mention the code is access 2000 runable.
--
Mvh Benny Andersen
Nov 13 '05 #3

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.