Opening Modules & Auto Editing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I see how I can open the database's modules. I would like to reformat my tab
spacing and update some calls.

Is there a way to open the module and then update the text?

Here is some sample code:

Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllTables collection.
For Each obj In dbs.AllTables
If (Left(obj.Name, 4) <> "MSys") Then
Debug.Print obj.Name, obj.Type
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name & " is loaded"
End If
End If
Next obj
 
Please explain what you want to do. What tab spacing are you referring to?
What calls? Nothing like that in tables, AFAIK

Damon
 
I would like to reformat my code with "proper indenting" for my loops and
if's. I also have error code numbers in the modules I would like to clean up.

Ken
 
Well, for indenting, that is easy. There is a free routine to do just that.
It works great.

http://www.bmsltd.ie/Excel/SBXLPage.asp

What is the other problem? If this is an mdb file, then just go to the code
window. Open a form in design view, and click on the code icon. If you
compiled the db into mde, then you can't do this. Work on the mdb copy.


Damon
 
Damon - that web site has a lot of great information...

My other issue is I would like to be able to renumber my error codes that I
generate when I check the data in my tables. I have a number of functions
that check the data in tables. I can not check the data as it is already in
tables.

I have a table that lists all the errors for index's across the tables. In
order to find the code that generated the error I assigned each error a
unique ID and I would like to be able to renumber these automatically without
having to edit each function by hand.

Once I found I could open the modules via the allmodules method I was hoping
there was then a way to manipulate the text within a module.
 
Yes, you want to download VBAIndentor.exe from that web site. It will show
up after install, in the VB Edit menu as Smart Indent.

I am still confused by what IDs you want changed. Are they IDs in a table,
or IDs in code?

Damon
 
We are getting beyond my field of experience, so
I can only think of a real kludge answer... that is, if you are talking
about cycling thru your code in a module.
Lets say you have all of your code in a single module that has the IDs
imbedded in the code. Create a blank form with a cmd button on it and a
text box.

In the cmd buttons click event, enter:
Dim mystr As String
Dim ct As Integer
mystr = Me.Text1 'your textbox on the form
For ct = 1 To 60 'however many instances of numbers you want to change
mystr = Replace(mystr, "errmsg" & ct, "errmsg" & ct + 100, 1, 1, 1)
Next ct
Debug.Print mystr

Save the form. Go to the module, and select all of the module code, click
copy.
Open the form, and paste your code to the textbox.
Click the command button, and the replace function will cycle thru all the
instances of "errmsg1", "errmsg2", etc. and replace with errmsg101,
errmsg102, etc. then you just copy the debug txt in the immediate window
and paste it back to your module.

Obviously, I don't know how your number system is set up, so this may not
work. If I could see a piece of your code that you want to change......
If the numbers are more or less random, then you will have to
manually change them.

Damon
 
Back
Top