• ChangeStartupProperties not working in MDE (A2K SR1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » ChangeStartupProperties not working in MDE (A2K SR1)

    Author
    Topic
    #375741

    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

    Viewing 3 reply threads
    Author
    Replies
    • #612750

      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.

    • #612757

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

      • #612840

        I used the compiler directive as it was suggested in the Help file 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.

    • #612768

      … 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.

    • #612776

      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.

      • #612838

        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 ?

      • #613376

        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.

    Viewing 3 reply threads
    Reply To: Reply #612768 in ChangeStartupProperties not working in MDE (A2K SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel