[AccessD] Database Startup Properties

jeffrey.demulling at usbank.com jeffrey.demulling at usbank.com
Mon May 10 15:11:12 CDT 2004


Hopefully this can help you get started.  I have it in my splash screen.

'Now if the user is marked as being a programmer ask what mode to open
application
    con = setconnection
    con.Open

    cmdtext = "SELECT"
    cmdtext = cmdtext & " tblUsers.[User LAN Id],"
    cmdtext = cmdtext & " tblUsers.[User Name],"
    cmdtext = cmdtext & " tblUsers.Programmer"
    cmdtext = cmdtext & " FROM"
    cmdtext = cmdtext & " tblUsers"
    cmdtext = cmdtext & " WHERE"
    cmdtext = cmdtext & " tblUsers.[User LAN Id]='" & GetTheCurrentUser &
"'"
    cmdtext = cmdtext & " AND"
    cmdtext = cmdtext & " tblUsers.Programmer<>0;"

    rs.Open cmdtext, con

    If Not rs.EOF And Not rs.BOF Then    'User is a programmer
        rs.MoveFirst
        mymessage = "Hello " & rs.Fields("User Name") & Chr(10) & Chr(13)
        mymessage = mymessage & "Open Application for Repairs/Debugging?"
        myresponse = MsgBox(mymessage, 36, "Question")

        'Close the connection
        con.Close

        If myresponse = 6 Then    'Open application in design mode -
ansewered yes to question
            mymessage = "Opening Application in Design Mode." & Chr(10) &
Chr(13)
            mymessage = mymessage & "Please don't hurt me to much."

            ChangeProperty "StartupForm", dbText, "frmSplash"
            ChangeProperty "StartupShowDBWindow", dbBoolean, True
            ChangeProperty "StartupShowStatusBar", dbBoolean, True
            ChangeProperty "AllowBuiltinToolbars", dbBoolean, True
            ChangeProperty "AllowFullMenus", dbBoolean, True
            ChangeProperty "AllowBreakIntoCode", dbBoolean, True
            ChangeProperty "AllowSpecialKeys", dbBoolean, True
            ChangeProperty "AllowBypassKey", dbBoolean, True

            DoCmd.ShowToolbar "Menu Bar"

            MsgBox mymessage, vbOKOnly, "Welcome"

            DoCmd.Close acForm, "frmSplash"
            Exit Sub
        Else    'Open in normal mode - ansewered no to question
            mymessage = "Opening Application for Normal Use." & Chr(10) &
Chr(13)
            mymessage = mymessage & "Have a nice day."

            MsgBox mymessage, vbOKOnly, "Welcome"

            DoCmd.OpenForm "frmMainMenu"
            Exit Sub
        End If
    Else
        con.Close

        cmdtext = "SELECT"
        cmdtext = cmdtext & " tblUsers.[User LAN Id],"
        cmdtext = cmdtext & " tblUsers.[User Name]"
        cmdtext = cmdtext & " FROM"
        cmdtext = cmdtext & " tblUsers"
        cmdtext = cmdtext & " WHERE"
        cmdtext = cmdtext & " tblUsers.[User LAN Id]='" & GetTheCurrentUser
& "';"

        con = setconnection
        con.Open

        rs.Open cmdtext, con

        rs.MoveFirst
        mymessage = "Hello " & rs.Fields("User Name") & Chr(10) & Chr(13)
        mymessage = mymessage & "I have determined that you are an
authorized user." & Chr(10) & Chr(13)
        mymessage = mymessage & "Please feel free to proceed and have a
nice day."

        'Close the connection
        con.Close

        ChangeProperty "StartupForm", dbText, "frmSplash"
        ChangeProperty "StartupShowDBWindow", dbBoolean, False
        ChangeProperty "StartupShowStatusBar", dbBoolean, True
        ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
        ChangeProperty "AllowFullMenus", dbBoolean, False
        ChangeProperty "AllowBreakIntoCode", dbBoolean, False
        ChangeProperty "AllowSpecialKeys", dbBoolean, False
        ChangeProperty "AllowBypassKey", dbBoolean, False

        Application.SetOption "Error Trapping", 2

        MsgBox mymessage, vbOKOnly, "Welcome"

        DoCmd.OpenForm "frmMainMenu"
        Exit Sub
    End If




Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
    Dim dbs As DAO.database
    Dim prp As DAO.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


                                                                                                                                               
                      "Mitsules, Mark S.                                                                                                       
                      (Newport News)"                  To:       "'[AccessD]'" <AccessD at databaseadvisors.com>                                  
                      <Mark.Mitsules at ngc.com>          cc:                                                                                     
                      Sent by:                         Subject:  [AccessD] Database Startup Properties                                         
                      accessd-bounces at databasea                                                                                                
                      dvisors.com                                                                                                              
                                                                                                                                               
                                                                                                                                               
                      05/10/2004 02:48 PM                                                                                                      
                      Please respond to "Access                                                                                                
                      Developers discussion and                                                                                                
                      problem solving"                                                                                                         
                                                                                                                                               
                                                                                                                                               




Can someone point me in the direction of a short tutorial on database
startup properties?  I have seen tools for setting these properties
remotely
ala http://www.jamiessoftware.tk/propeditor/pe_download.html, but I'm
looking for examples on how to roll-my-own.  I'm trying to create an
automated routine that toggles all the appropriate properties for an
administrator login (full menus, shortcuts, show database window, etc.).



Mark
--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com









More information about the AccessD mailing list