Solved

How to set VBA Options via Code

Posted on 2011-02-15
5
397 Views
Last Modified: 2013-11-27
Is it possible to set the VBA Options Compile On Demand and Background Compile via VBA code?
0
Comment
Question by:Milewskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:RgGray3
ID: 34901321
I haven't seen it....
I have code to toggle other Access options...  havent seen that one exposed....  though you have me curious.  So I am searching....

But, to what end?   why would you need/want to toggle this via code?

just curious....  
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 34903557
there is no way to set those in VBA
if you want to do it in codes, you have to change the registry setting

HKEY_CURRENT_USER\Software\Microsoft\VBA\6.0\Common


BackgroundCompile Dword   (0 = Unchecked, 1 = Checked)
CompileOnDemand, Dword  (0 = Unchecked, 1 = Checked)
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34906719
hi RgGray3,
<why would you need/want to toggle this via code?>
I would like to be able to initialize these options to my preferred values whenever I open a database (in case I had chanegd them temporarily, or in case I copy my database to another PC).
0
 
LVL 11

Assisted Solution

by:RgGray3
RgGray3 earned 250 total points
ID: 34906829
Interesting...   It's not a setting I have given much thought to changing.

OK   well as stated by Capricorn1...  those settings are in the registry...  (Thanks Cap......) Sure enough those and a few others are hanging out there.
So you would need to update the registry..

There are API routines that allow you to read and write to the registry
(Angels..  tread carefully)
Create a wrapper to toggle the specific entries.

Check MS KB....

http://support.microsoft.com/kb/145679





0
 
LVL 1

Author Comment

by:Milewskp
ID: 34951763
Thanks for the help gents, I'll spilt the points.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question