473,836 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is It possible to set Access Startup Options using VBA?

twinnyfo
3,653 Recognized Expert Moderator Specialist
I am using MS Access 2007.

I have a database that I do all my editing and programming in and have certain Access options (under the Current Database tab) set one way during the editing. However, when I compile the database into the .accde file, I reopen the database and set certain options, such as the initial display form and navigation pane options. I keep these enabled during programming for ease of use, but disable them whem compiled to prevent others from possibly using them (or at least making it more difficult).

Is it possible to use VBA to set these options to automate this process after the compile? I already have code re-mapping all my linked tables and modifying/deleting unused Switchboard items.

Does anyone have any experience with this?Thanks!
Dec 7 '11 #1
13 14673
ADezii
8,834 Recognized Expert Expert
I think you are referring to the StartUp Properties of a Database and yes, they can be modified but it is a little tricky since they are User Defined Properties and cannot be Set/Retrieved in the conventional manner. If the Property exists, you can directly modify it, if not you must create it then Append it to the proper Collection. The Code below will set the Allow Full Menus Start Up DB Option to False:
  1. Function Definition:
    Expand|Select|Wrap|Line Numbers
    1. Private Function ChangeProperty(strPropertyName As String, varPropertyType As Variant, varPropertyValue As Variant) As Integer
    2. On Error GoTo Err_ChangeProperty
    3. Dim MyDB As DAO.Database
    4. Dim MyProperty As DAO.Property
    5.  
    6. Set MyDB = CurrentDb()
    7.  
    8. 'Property exists, so set its Value
    9. MyDB.Properties(strPropertyName) = varPropertyValue
    10. ChangeProperty = True
    11.  
    12. Exit_ChangeProperty:
    13.   Exit Function
    14.  
    15. Err_ChangeProperty:
    16.   If Err.Number = 3270 Then       'Property not found
    17.     'Since the Property isn't found, create it!
    18.     Set MyProperty = MyDB.CreateProperty(strPropertyName, varPropertyType, varPropertyValue)
    19.     MyDB.Properties.Append MyProperty
    20.       Resume Next
    21.   Else
    22.    'Unknown Error
    23.    ChangeProperty = False
    24.      Resume Exit_ChangeProperty
    25.   End If
    26. End Function
  2. Function Call:
    Expand|Select|Wrap|Line Numbers
    1. ChangeProperty "AllowFullMenus", dbBoolean, False
Dec 8 '11 #2
twinnyfo
3,653 Recognized Expert Moderator Specialist
Thanks ADezii,

BRILLIANT! That worked perfectly for turning off full menus. However, where does one find the names of these other properties, such as Allow Default Shortcut Menus and the like? I've tried some variations and nothing seems to work.

Also, how does one use VBA to tell the Database to open a specific form when it opens? Doing it manually is easy, but I have no clue where to start doing this in VBA....

Thanks for your help so far!
Dec 8 '11 #3
ADezii
8,834 Recognized Expert Expert
All the answers to your questions are listed below:
Expand|Select|Wrap|Line Numbers
  1. Text in Startup Dialog Box         Property name
  2. -------------------------------------------------------------
  3. Application Title                  AppTitle
  4. Application Icon                   AppIcon
  5. Display Form/Page                  StartupForm
  6. Display Database Window            StartupShowDBWindow
  7. Display Status Bar                 StartupShowStatusBar
  8. Menu Bar                           StartupMenuBar
  9. Shortcut Menu Bar                  StartupShortcutMenuBar
  10. Allow Full Menus                   AllowFullMenus
  11. Allow Default Shortcut Menus       AllowShortcutMenus
  12. Allow Built-In Toolbars            AllowBuiltInToolbars
  13. Allow Toolbar/Menu Changes         AllowToolbarChanges
  14. Allow Viewing Code After Error     AllowBreakIntoCode
  15. Use Access Special Keys            AllowSpecialKeys
Dec 8 '11 #4
twinnyfo
3,653 Recognized Expert Moderator Specialist
ADezii,

Thank ou again! I wish MS made this stuff more readily available. I was certain I had already tried some of those properties but they didn't work. This time, works like a charm!

Warmest regards!
Dec 8 '11 #5
ADezii
8,834 Recognized Expert Expert
@twinnyfo:
It is not at all intuitive on how you can Set/Retrieve these Properties.
Dec 8 '11 #6
Mihail
759 Contributor
Thank you too, ADezii.
This post is just to subscribe.

By the way: Can I subscribe to a thread without posting something in that thread (and disturb the others) ?
Dec 8 '11 #7
ADezii
8,834 Recognized Expert Expert
@Mihail:
Can I subscribe to a thread without posting something in that thread (and disturb the others)?
I actually not 100% sure, but the person to direct this Question to would be NeoPa. Send him a Private Message with this same Question, and I'm sure he will reply to you.
Dec 8 '11 #8
NeoPa
32,584 Recognized Expert Moderator MVP
Not currently, but there used to be such a facility and we expect there to be such again in a future version of the site :-)
Dec 8 '11 #9
NeoPa
32,584 Recognized Expert Moderator MVP
That was so useful that I decided to create a module specifically to support working with Properties in Access. Reading, writing, adding and deleting are all supported, and even though the VarType() function returns values in a similar but incompatible set from the dbXXX type values required by CreateProperty( ), I thought it was worthwhile to handle that with a little conversion function that handles the most common and those likely to be used with property values.

The code all seems to work :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Const conNoProp As Integer = 3270
  5. Private Const conVBToDB As String = "\2|3\3|4\4|6\5|7\6|5" & _
  6.                                     "\7|8\8|10\11|1\14|20\17|2"
  7.  
  8. 'SetProperty() requires that either intPType is set explicitly OR that
  9. '              varPVal has a valid value if a new property is to be created.
  10. Public Sub SetProperty(strPName As String, varPVal As Variant, _
  11.                        Optional ByVal db As DAO.Database, _
  12.                        Optional intPType As Integer = -1)
  13.     Dim prp As DAO.Property
  14.  
  15.     If db Is Nothing Then Set db = CurrentDb
  16.     If PropertyExists(strPName, db) Then
  17.         db.Properties(strPName) = varPVal
  18.     Else
  19.         If intPType = -1 Then intPType = DBVal(VarType(varPVal))
  20.         Set prp = db.CreateProperty(strPName, intPType, varPVal)
  21.         Call db.Properties.Append(prp)
  22.     End If
  23. End Sub
  24.  
  25. Public Function GetProperty(ByRef strPName As String, _
  26.                             Optional ByVal db As DAO.Database) As Variant
  27.     If db Is Nothing Then Set db = CurrentDb
  28.     If PropertyExists(strPName, db) Then GetProperty = db.Properties(strPName)
  29. End Function
  30.  
  31. Public Function PropertyExists(ByRef strPName As String, _
  32.                                Optional ByVal db As DAO.Database) As Boolean
  33.     Dim varTest As Variant
  34.  
  35.     On Error GoTo Err_PropertyExists
  36.     If db Is Nothing Then Set db = CurrentDb
  37.     PropertyExists = True
  38.     varTest = db.Properties(strPName)
  39.     Exit Function
  40.  
  41. Err_PropertyExists:
  42.     If Err <> conNoProp Then
  43.         On Error GoTo 0
  44.         Resume
  45.     End If
  46.     PropertyExists = False
  47. End Function
  48.  
  49. Public Sub DelProperty(ByRef strPName As String, _
  50.                        Optional ByVal db As DAO.Database)
  51.     If db Is Nothing Then Set db = CurrentDb
  52.     If Not PropertyExists(strPName, db) Then Exit Sub
  53.     Call db.Properties.Delete(strPName)
  54. End Sub
  55.  
  56. Private Function DBVal(intVBVal) As Integer
  57.     Dim intX As Integer
  58.  
  59.     intX = InStr(1, conVBToDB, "\" & intVBVal & "|")
  60.     DBVal = Val(Mid(conVBToDB, intX + Len(intVBVal) + 2))
  61. End Function
PS. Congrats to ADezii for helping to make such a complicated process into one that's now quite straightforward . With all this information such work should be a doddle in future.
Dec 8 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
15180
by: Sateesh | last post by:
Hi, Is it possible to access Lotus notes using Python? Can anyone provide me some pointers? Thanks Sateesh
2
3190
by: TechBoy | last post by:
Hello. Re: Access 2002-SP3 I have some options turned off under "Tools/Startup" area on my workstation. When I deploy my app to 5 users (who will all have a full blown version of Access 2002 on their PC's) I would like to disable some startup options programatically at runtime via VBA. I am looking for VBA code to turn off these options at application startup and turn them back on for the user when they shutdown my app:
3
1782
by: stueyh | last post by:
When attempting to connect to an Access 2000 DB using ADO.Net from within ASP.Net running under an impersonated local user account receiving the following error. ERROR Disk or network error. ERROR Driver's SQLSetConnectAttr failed ERROR Disk or network error Oracle ODBC connection works fine under the same user so assuming this is something to do with either Access specific registry permissions, or NTFS
4
1938
by: silverburgh.meryl | last post by:
I am currently access this newsgroup thru Google group web interface. Is it possible to access this newsgroup using Thunderbird? Thank you.
3
1628
by: Gerrit Snel | last post by:
We have a question but we're in doubt if it's even possible or not. The question is as follows: Is it possible to access a form using a string literal, and if so yes? We want to use something like this (don't mind the syntax as it obviously doesn't work): Form("Form1") frm = ("Form1")GetForm("Form1");
1
2683
by: Andy | last post by:
Hi, I was wondering if someone could advise on if the following is possible. I have one website that is available to the public using Forms authentication and the Membership class, it creates/stores user information in a SQL Server 2005 db. I have another website that will administer the first website, allowing admins to look at all of the users in the db and see specific info from the database.The admin site is more secure than the...
2
4555
by: pratcp | last post by:
I have a remote server (a shared hosting webserver) where I have few users ftp some flat files. I need to access these files using a windows app/windows service written using c# and run it on a nightly basis. How do I access the remote server in a c# windows service or console app? The reason I need remote access is that I cannot have any type of schedule jobs running on a shared hosting webserver. I was contemplating on using SSIS sql...
2
1607
by: DebbyS | last post by:
Hi there, I am currently in the situation where I have a database secured with startup options and passwords, but need to edit the startup options from time to time.(These have been hidden). There is an article on MSDN about creating a form within a database to control these options - can anyone help.The Property Editor does not work as I have user accounts and groups and I cannot afford to go without them. I am not going to buy the entire...
4
44119
JodiPhillips
by: JodiPhillips | last post by:
MS Access2000 Hi everyone, I've searched the forums for an answer to this question and nothing jumps out at me. When a database is opened I want to automatically run code (at start-up) that compares the path of the opened database to a specific path (where the original database is located). This is for security reasons - I need to know if the original database has been copied without authorisation. Due to network issues I cannot use...
8
3551
by: Bhuwan Bhaskar | last post by:
Hi, Can we access database (SQL) using AJAX ? Thanks, Bhuwan
0
9813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10832
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10584
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10248
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.