Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ChangeStartupProperties not working in MDE (A2K SR1)

    I want to change the startup properties of my database programmatically. I tried to do it by having a Sub SetStartupProperties() which contains compiler directives #If..#Else..#End if. The directive constant conVersiMDE is declared at the declaration section, as the codes attached show. The Sub was the first to be run when the database was started.

    It works as exepcted when my application is run as a MDB file. However when it was compiled and run as a MDE, properties like "AllowShortcutMenus", "AllowSpecialKeys" and "AllowBypassKey" were still available and I could access my shortcut menu, the special keys as well as use Shift to bypass startup setup. Can anyone help?

    ----------------------------------------------

    #Const conVersiMDE = True

    Sub SetStartupProperties()

    Const DB_Text As Long = 10
    Const DB_Boolean As Long = 1

    ChangeProperty "StartupForm", DB_Text, "frmMula"
    ChangeProperty "AppTitle", DB_Text, "Pangkalan Data Murid"
    ChangeProperty "AppIcon", DB_Text, "Murid.ico"
    ChangeProperty "StartupMenuBar", DB_Text, "Murid Menu Bar"
    ChangeProperty "StartupShowDBWindow", DB_Boolean, False
    ChangeProperty "StartupShowStatusBar", DB_Boolean, True
    ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
    ChangeProperty "AllowToolbarChanges", DB_Boolean, False

    #If conVersiMDE Then
    ChangeProperty "AllowShortcutMenus", DB_Boolean, False
    ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
    ChangeProperty "AllowFullMenus", DB_Boolean, False
    ChangeProperty "AllowSpecialKeys", DB_Boolean, False
    ChangeProperty "AllowBypassKey", DB_Boolean, False
    Application.VBE.MainWindow.Visible = False
    #Else
    ChangeProperty "AllowShortcutMenus", DB_Boolean, True
    ChangeProperty "AllowBuiltinToolbars", DB_Boolean, True
    ChangeProperty "AllowFullMenus", DB_Boolean, True
    ChangeProperty "AllowSpecialKeys", DB_Boolean, True
    ChangeProperty "AllowBypassKey", DB_Boolean, True
    #End If

    End Sub

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    I don't think you can do this with an MDE as it is in a compiled state, and the settings must be remembered across closing the database and reopening it. Perhaps others can suggest a method for doing it from another database, but I'm dubious.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    Why do you need conditional compilation for this? Try using an ordinary constant (or variable) instead.

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    ... I have similar commands put in a module in an MDE ... and use a command button to execute the module before posting the database. However, you could try launching the module via command line arguments at startup in the MDE. Just some thoughts.
    Regards,

    Gary
    (It's been a while!)

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    Since the MDE is compiled, the only instructions that are in it match whatever the value of the compiler constant was when you compiled and created the MDE. You can't use compiler statements this way.
    Charlotte

  6. #6
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    I deleted the conditional compiler directive and just left the codes like belows:

    -----------------------------
    Sub SetStartupProperties()

    Const DB_Text As Long = 10
    Const DB_Boolean As Long = 1

    ChangeProperty "AllowShortcutMenus", DB_Boolean, False
    ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
    ChangeProperty "AllowFullMenus", DB_Boolean, False
    ChangeProperty "AllowSpecialKeys", DB_Boolean, False
    ChangeProperty "AllowBypassKey", DB_Boolean, False
    Application.VBE.MainWindow.Visible = False

    End Sub
    ---------------------------------

    Still the Startup properties didn't change, and the Shift bypass key happily displayed my database windows on startup and the shortcut menu could be popped up by right-clicking.

    I am curious why it works in MDB and not in MDE. Is it my mistake or a designed feature of A2K [img]/forums/images/smilies/smile.gif[/img]?

  7. #7
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    I used the compiler directive as it was suggested in the Help file [img]/forums/images/smilies/smile.gif[/img] It worked when I wanted to change from docmd.close (#Const conVersiMDE = False) in MDB to docmd.quit when I made it into a MDE (#Const conVersiMDE = True). I was using a const before I used #const. Both worked well.

  8. #8
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeStartupProperties not working in MDE (A2K SR1)

    I discovered by accident and after several trials that the MDE does change its startup properties as dictated by the conditional compilation - the MDE has to be bypassed by using Shift, and then allowed to run the program once before the changed startup properties can be activated. I don't know why it behaved this way. If the MDE was run immediately it was made and after exiting from Access, the startup properties weren't changed as expected from the conditional compilation.

    I forgot to mention - the sub ChangeProperty() was extracted from the VBA Help file.

Posting Permissions

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