Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to set VBA Options via Code

Posted on 2011-02-15
5
Medium Priority
?
417 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
  • 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 1000 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 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

971 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