[AccessD] How to automatically add "Option Explicit" to existingcode modules

Rocky Smolin rockysmolin at bchacc.com
Wed Nov 10 18:48:37 CST 2010


Darryl:

 You need to set up  loops to cycle through each form, report, and module
and insert the line. Assuming that "Option Compare Database" is line 1 of
each module:

	frm.Module.InsertLines 2, "Option Explicit"
Or 
	rpt.Module.InsertLines 2, "Option Explicit"

Etc.

I did this years ago so it's a bit hard to remember - creating event
procedures.  

Here's some samples of adding code through code:

http://msdn.microsoft.com/en-us/library/aa221350%28office.11%29.aspx

Even more to the point:

http://msdn.microsoft.com/en-us/library/aa443960%28v=VS.60%29.aspx 

HTH

Rocky


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darryl Collins
Sent: Wednesday, November 10, 2010 3:59 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] How to automatically add "Option Explicit" to
existingcode modules


____________________________________________________________________________
___________

Note: This e-mail is subject to the disclaimer contained at the bottom of
this message.
____________________________________________________________________________
___________


Hi folks,

"How to add "Option Explicit" to existing code modules"

I am not optimistic about this one as a Google search was fairly fruitless,
although I did find one tool suite that claimed to do this, but is is $200+
for a single user license so I lost interest at that point.  Maybe I am not
searching with the best keywords.

I am working on databases largely built by others and none of them use
"Option Explict".  As a result there are dozens of little code errors that
reveal themselves when explict is turned on. 

Of course the first thing I do is turn this option on, but that only applys
to any new modules added.  Clearly I can manually paste in 'Option Explicit'
into every existing form, report & code module, but there are hundreds of
the little buggers and I would prefer not to have to do this manually.

Does anyone has some sneaky cheeky code that will check for option explict
and write it into the form/module etc if it is missing?  I would of thought
this would have been a fairly useful thing to do - and a standard option to
have from the VBE, but hey, what do I know :)

cheers
Darryl
____________________________________________________________________________
___________

The information transmitted in this message and its attachments (if any) is
intended only for the person or entity to which it is addressed.
The message may contain confidential and/or privileged material. Any review,
retransmission, dissemination or other use of, or taking of any action in
reliance upon this information, by persons or entities other than the
intended recipient is prohibited.

If you have received this in error, please contact the sender and delete
this e-mail and associated material from any computer.

The intended recipient of this e-mail may only use, reproduce, disclose or
distribute the information contained in this e-mail and any attached files,
with the permission of the sender.

This message has been scanned for viruses.
____________________________________________________________________________
___________

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list