How to use Startup form dynamically

vsap

vsap
Local time
Today, 00:05
Joined
May 27, 2005
Messages
29
Hello Guys,
I have proj name m1.mdb which has forms and reports.I have 2 forms form1 ,form2.In form2 I have button that creates new database named m2_date.mdb and creates report and form1 by using property DoCmd.TransferDatabase acExport, "Microsoft Access", sFilename, acForm, "form1", "form1", StructureOnly, StoreLogin,now this form1 has to be seen first when any user doubleclicks m2_user.mdb,so my question is, is there any way i can setup startup form properties dynamically ,without using startup form manually from tool properties of toolbar.
hope to get answer..
thanks
vsap
 
There are functions to run to do what you want. Below should be enough to get you started. You just need to replace the text strings where needed and/or turn the option on or off with a True or False. Be careful how you use these for you can lock yourself out if you turn the Bypass Key off! You should test this code with a temp database until you know what you are doing!

Code:
Public Sub SetStartupProperties()
On Error GoTo Err_SetStartupProperties
    
        SetProperties "StartupForm", dbText, "YourStartUpFormNameHere"
        SetProperties "StartupMenuBar", dbText, "YourCustomToolbarNameHere"
        SetProperties "StartupShowDBWindow", dbBoolean, False
        SetProperties "StartupShowStatusBar", dbBoolean, True
        SetProperties "StartupShortcutMenuBar", dbBoolean, True
        SetProperties "AllowBreakIntoCode", dbBoolean, True
        SetProperties "AllowBuiltinToolbars", dbBoolean, True
        SetProperties "AllowBypassKey", dbBoolean, True
        SetProperties "AllowFullMenus", dbBoolean, True
        SetProperties "AllowSpecialKeys", dbBoolean, True
        SetProperties "AllowShortcutMenus", dbBoolean, True
        SetProperties "AllowToolbarChanges", dbBoolean, True

Exit_SetStartupProperties:
    Exit Sub

Err_SetStartupProperties:
    MsgBox  Err.Number & " - " & Err.Description
    Resume Exit_SetStartupProperties

End Sub

'This function will create the set properties if and when needed...
Code:
Public Function SetProperties(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties

    Dim db As Database
    Dim prp As Property
'    Const conPropNotFoundError = 3270

    Set db = CurrentDb

    db.Properties(strPropName) = varPropValue
    SetProperties = True

    Set db = Nothing

Exit_SetProperties:
    Exit Function

Err_SetProperties:
    If Err.Number = 3270 Then  'Property not found
        Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
        db.Properties.Append prp
        Resume Next
    Else
        SetProperties = False
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_SetProperties
    End If

End Function
 

Users who are viewing this thread

Back
Top Bottom