Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    104

    Unanswered: Setting Startup properties AND controls using code?

    Hi All,
    this thread is split into two main ideas or questions

    1.) How Can The Startup properties be set/unset using code (see picture)

    http://shassouneh.homestead.com/file...susingCode.jpg

    2.) How can ALL the controls be restored so that the user gains FULL CONTROL over everything? For Instance, right now I created an MDE and the user cannot change table structure. If i re open the MDB file these 'controls' are sitll disabled. How can I use code to "unlock everything"

    Please do not hesitate to rpely if you cna help. Thanx

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    To change the Access Startup Properties via code, you can use this little function. Place it into your main database code module:

    Code:
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    	'Function used to change the Startup Options
    	'in Microsoft Access.
    	Dim dbs As Database, prp As Property
    	Const conPropNotFoundError = 3270
    	Set dbs = CurrentDb
    	On Error GoTo Change_Err
    	
    	dbs.Properties(strPropName) = varPropValue
    	ChangeProperty = True
    
    Change_Bye:
    	Exit Function
    
    Change_Err:
    	If Err = conPropNotFoundError Then  ' Property not found.
    		Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    		dbs.Properties.Append prp
    		Resume Next
    	Else
    		' Unknown error.
    		ChangeProperty = False
    		Resume Change_Bye
    	End If
    End Function
    __________________________________________________ ____________________

    Here are examples of how to use this Function:
    Code:
       'Turn specific Startup Options OFF.   
       ChangeProperty "AllowFullMenus", dbBoolean, False
       ChangeProperty "AllowBreakIntoCode", dbBoolean, False
       ChangeProperty "AllowSpecialKeys", dbBoolean, False
       ChangeProperty "AllowBypassKey", dbBoolean, False
       ChangeProperty "AllowToolbarChanges", dbBoolean, False
    Code:
    	'Turn specific Startup Options ON.
    	ChangeProperty "AllowFullMenus", dbBoolean, True
    	ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    	ChangeProperty "AllowSpecialKeys", dbBoolean, True
    	ChangeProperty "AllowBypassKey", dbBoolean, True
    	ChangeProperty "AllowToolbarChanges", dbBoolean, True
    Keep in mind though...you will always need to restart your database before the options will take effect. ALSO, you must make sure that the Option name (such as "AllowBypassKey") is spelled correctly.


  3. #3
    Join Date
    Nov 2003
    Posts
    104
    Thanx for the reply. it helps a lot. However, I still have 2 problems

    1.) Changing the properties (as shown below) then closing/restarting Access does NOT re-show all menus, etc

    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, True
    ChangeProperty "AllowToolbarChanges", dbBoolean, True

    2.) Right Clicking an object like a table or form or anything does not do anything

    I would like for # 1 and 2 to work.

    Any ideas?

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    I've just this second posted something that might help you.
    http://www.dbforums.com/t998240.html

    Also, you can programmatically change some of the settings from the Options dialog box (and some other things) through the application object, if this would help.

    Application.SetOption "Show Hidden Objects", False
    Application.SetOption "Error Trapping", 1
    Application.MenuBar = "limited_menu"

    Also, I find it useful when you are doing this sort of thing to provide yourself with a "backdoor" so you can restore these options should you make an error.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •