Missing option properties when creating database from VBA

Anonymous
2023-04-17T18:29:32+00:00

Hello,

When creating a database from VBA code with Access 2021, I noticed that some option properties were missing in my created database.

Here is some VBA code that shows this.

 Set db = DBEngine.Workspaces(0).CreateDatabase(strPathDataBaseViewRibbon & "\" & nameDataBaseViewRibbon, dbLangGeneral) 

DoCmd.TransferDatabase acExport, "Microsoft Access", filePathDataBase, acForm, "ViewRibbon", "ViewRibbon", False 

Debug.Print "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" 

Debug.Print "Create database" 

Debug.Print "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" 

For Each prp In db.Properties 

    Debug.Print prp.name 

Next prp 

Debug.Print "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" 

Debug.Print "Current database" 

Debug.Print "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" 

Set db1 = CurrentDb 

For Each prp In db1.Properties 

    Debug.Print prp.name 

Next prp 

'db.Properties ("useMDIMode") = 1 'onglet 

db.Close

Here is the properties display for the created database and my current database.

We can see that the database created in VBA has much less option properties.

Checking the database created in VBA, I noticed in the options that the document window setting was overlapping window selection.

If I select the "tabbed documents" view and then list the option properties, I find all the properties.

How to create in VBA the database so that the document display is in the form of a tab?

The "useMDIMode" property which can position the display by tab is missing when creating the database in VBA.

db.Properties("useMDIMode") = 0 gives an error.

Microsoft 365 Insider | Access | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-04-18T18:11:28+00:00

    Hello,

    To solve this problem, I added the missing properties used to my database created in VBA from the <Append> method of the properties.

    Here is a part of VBA code

    Dim db As Database 
    
    Dim pty As Property
    
    .....
    
    .....
    
    On Error GoTo Gesterr1 
    
    'Crée la base de la base de données servant à visualiser le ruban 
    
    Set db = DBEngine.Workspaces(0).CreateDatabase(strPathDataBaseViewRibbon & "\" & nameDataBaseViewRibbon, dbLangGeneral) 
    
    'Transfert le formulaire 
    
    DoCmd.TransferDatabase acExport, "Microsoft Access", filePathDataBase, acForm, "ViewTest", "ViewTest", False 
    
    On Error GoTo 0 
    
    'Crée les différentes propriétés des options 
    
    'Affichage des documents sous forme d'onglets 
    
    On Error Resume Next 
    
    Set pty = db.Properties("UseMDIMode") 
    
    On Error GoTo 0 
    
    If pty Is Nothing Then 
    
        db.Properties.Append db.CreateProperty("UseMDIMode", dbByte, 0) 
    
    Else 
    
        db.Properties("UseMDIMode") = 0 
    
    End If 
    
    'Nom du formulaire de démarrage 
    
    On Error Resume Next 
    
    Set pty = db.Properties("StartUpForm") 
    
    On Error GoTo 0 
    
    If pty Is Nothing Then 
    
        db.Properties.Append db.CreateProperty("StartUpForm", dbText, "ViewTest") 
    
    Else 
    
        db.Properties("StartUpForm") = "ViewRibbon" 
    
    End If 
    
    'Pas d'affichage du volet de navigation 
    
    On Error Resume Next 
    
    Set pty = db.Properties("StartUpShowDBWindow") 
    
    On Error GoTo 0 
    
    If pty Is Nothing Then 
    
        db.Properties.Append db.CreateProperty("StartUpShowDBWindow", dbBoolean, False) 
    
    Else 
    
        db.Properties("StartUpShowDBWindow") = False 
    
    End If 
    
    'Pas d'affichage des menus intégrés complets
    
    On Error Resume Next 
    
    Set pty = db.Properties("AllowFullMenus") 
    
    On Error GoTo 0 
    
    If pty Is Nothing Then 
    
        db.Properties.Append db.CreateProperty("AllowFullMenus", dbBoolean, False) 
    
    Else 
    
        db.Properties("AllowFullMenus") = False 
    
    End If 
    
    'Pas d'affichage des menus contextuels intégrés 
    
    On Error Resume Next 
    
    Set pty = db.Properties("AllowShortcutMenus") 
    
    On Error GoTo 0 
    
    If pty Is Nothing Then 
    
        db.Properties.Append db.CreateProperty("AllowShortcutMenus", dbBoolean, False) 
    
    Else 
    
        db.Properties("AllowShortcutMenus") = False 
    
    End If 
    
    db.Close 
    

    .....

    .....

    I also noticed that the <StartUpForm> option property was not present in the large list of option properties for the current database.

    0 comments No comments
  2. Anonymous
    2023-05-09T07:59:41+00:00

    my microsoft office does ot work why ?

    0 comments No comments