Solved

Setting "Tabbed Documents" via VBA on an MS Access 2010 database

Posted on 2014-03-31
6
1,879 Views
Last Modified: 2014-04-06
To whom it may concern:
Could you tell me how to programmatically (VBA) set an MS Access 2010 database to "Tabbed Documents" instead of "Overlapping Windows"?  I am creating a new MS Access 2010 database and I would like it to have this feature when a user opens the database.  I have tried the two sets of code below and they both don't seem to work.  I am not sure why either.

Try 1:
    Call SetPropertyDAO(db, "AllowDatasheetSchema", dbBoolean, False, strMsg)
    Call SetPropertyDAO(db, "DesignWithData", dbLong, mlngcAllowLayoutView, strMsg)
   
    'Preferences for child windows.
    Call SetPropertyDAO(db, "UseMDIMode", dbByte, 0, strMsg)
    Call SetPropertyDAO(db, "ShowDocumentTabs", dbBoolean, True, strMsg)

Try 2:
  db.Properties("UseMDIMode") = 0

Thank you for your help.
0
Comment
Question by:kylelinkuhn
  • 3
  • 3
6 Comments
 
LVL 84
ID: 39967314
What does "SetProperty" do?

Remember that many of the Access properties do not exist until needed, so often you must create the property if it's missing, so your "ShowDocumentTabs" property may not yet exist.
0
 

Author Comment

by:kylelinkuhn
ID: 39967335
Sorry about that.  Here are the procedures that are missing from my explanation above.


Private Function SetPropertyDAO(obj As Object, strPropertyName As String, intType As Integer, _
    varValue As Variant, Optional strErrMsg As String) As Boolean
On Error GoTo ErrHandler
    'Purpose:   Set a property for an object, creating if necessary.
    'Arguments: obj = the object whose property should be set.
    '           strPropertyName = the name of the property to set.
    '           intType = the type of property (needed for creating)
    '           varValue = the value to set this property to.
    '           strErrMsg = string to append any error message to.

    If HasProperty(obj, strPropertyName) Then
        obj.Properties(strPropertyName) = varValue
    Else
        obj.Properties.Append obj.CreateProperty(strPropertyName, intType, varValue)
    End If
    SetPropertyDAO = True

ExitHandler:
    Exit Function

ErrHandler:
    strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & " not set to " & varValue & _
        ". Error " & Err.Number & " - " & Err.Description & vbCrLf
    Resume ExitHandler
End Function

Private Function HasProperty(obj As Object, strPropName As String) As Boolean
    'Purpose:   Return true if the object has the property.
    Dim varDummy As Variant

    On Error Resume Next
    varDummy = obj.Properties(strPropName)
    HasProperty = (Err.Number = 0)
End Function
0
 
LVL 84
ID: 39967503
What is the value of "db"? That would need to be set to CurrentDb, or something of that nature.

Otherwise, the code looks like it should work.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:kylelinkuhn
ID: 39967554
db is the database that I want the "Tabbed Documents" to be set on, which is not the current database.  If I set db to the current db, will the database I create from it be set as "Tabbed Documents"?
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39967693
Yes, it should. But assuming you've set the "db" variable correctly, the code you show should work.

Can you set a breakpoint and see what's happening in the SetPropertyDAO code?
0
 

Author Closing Comment

by:kylelinkuhn
ID: 39981608
I figured out what I had done incorrectly.  The code worked correctly.  I thought I had the CurrentDb set correctly, but I didn't.  Thanks for your help.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now