Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically add a line of code to every sub 1

Status
Not open for further replies.

SeadnaS

Programmer
May 30, 2011
214
Hi Folks,

How can I add a line of code to every sub in an access VBA project. I need to add DoCmd.SetWarnings False to the start of each sub after the OnError. I really do not want to do this manually is there a quick snippet of code i can use in the immediate window to do this?

Thanks in advance.
 
You might want to ask this in forum707, as this forum is for VB5/6 and not VBA
 
Hi there,

a) this is the forum for VB6, not VBA
this question should be posed either in forum707 or - as this is about Access VBA - in forum705

b) if there is any characteristical line that occurs in every sub somewhere at the beginning of each code (e.g. one Dim i as Integer) standalone on one line, you could use a simple global search/replace.

In the Editor, hit CTRL+H (or edit->find/replace) to bring up the replace dialog.
Replace
Dim i as Integer
with
Dim i as Integer:DoCmd.SetWarnings False

The colon can be used to separate two "lines" even though they are written on the same line.

Hope this helps.

Cheers,
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
I have MZ tools 3.0 but i cant find what I need.

Apologies for posting in the wrong forum, I posted rather hastily.

Thanks for the tip MakeItSo, the only thing I have in every sub is my error handling goto.

Is it ok to do something like this at the start of each sub:

DoCmd.SetWarnings False: On Error GoTo BlahBlahSubWhatever_Err

Thanks again for the help guys.
 
Yeah, that should totally do it.

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top