Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-31
6
Medium Priority
?
2,240 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

618 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