?
Solved

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

Posted on 2014-03-31
6
Medium Priority
?
2,135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 85
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 85
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

801 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