Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Location
    Manchester, UK
    Posts
    1

    Question Unanswered: RTE 13 Type mismatch when Set-ing Properties

    Hi all

    Newbie here. Having scatched my head for several days and having failed to extricate myself from the brown stuff , I thought I'd throw up a distress flare. Can anyone tell me why this fails with "Run Time Error 13: Type Mismatch" ? :

    Sub TestP()
    Dim P As Properties
    Set P = CurrentDb.Containers(0).Properties
    End Sub

    ...whereas this works fine :

    Sub TestD()
    Dim D As Documents
    Set D = CurrentDb.Containers(0).Documents
    End Sub

    Fuller context at end. My brain appears to have turned to cheese!!!

    Cheers all


    Peter

    '******************************************
    Sub test()
    ' As I understand it...
    '
    ' Every database has eight (97) or nine (2003) Containers (depends on Access version)
    ' Each Container has a Documents collection and a Properties collection
    ' Container's Documents collection may have zero documents
    ' Container's Properties collection has six properties
    '
    ' Line fails below as detailed in comments...
    '

    Dim DB As Database
    Dim DB_Container_Documents As Documents
    Dim DB_Container_Properties As Properties

    Set DB = CurrentDb
    ' or use your own Db as an example if you prefer
    ' Const YOUR_DB_Name = "A.mdb"
    ' Set DB = OpenDatabase(CurDir & "\" & YOUR_DB_Name)

    Debug.Print DB.Containers.Count

    Debug.Print DB.Containers(0).Documents.Count
    Set DB_Container_Documents = DB.Containers(0).Documents
    Debug.Print DB_Container_Documents.Count

    Debug.Print DB.Containers(0).Properties.Count


    '************************************************
    ' the following FAILS - can you tell me why...
    '************************************************
    Set DB_Container_Properties = CurrentDb.Containers(0).Properties
    '************************************************
    ' why does
    ' "DB_Container_Properties" (which is declared as type "Properties")
    ' give a type mismatch wehn assigned to
    ' "CurrentDb.Containers(0).Properties"
    ' ????
    '************************************************

    Debug.Print DB_Container_Properties.Count

    Set DB_Container_Properties = Nothing
    Set DB_Container_Documents = Nothing
    Set DB = Nothing
    End Sub
    '******************************************

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    not directly responsive to your question, but a possible route towards a workaround:
    Code:
    Private Sub Props()
        Dim cntr As Container
        Dim prop As Property
        For Each cntr In CurrentDb.Containers
            Debug.Print cntr.Name
            For Each prop In cntr.Properties
                Debug.Print "   "; prop.Name; " = "; prop.Value
            Next
        Next
        Debug.Print "...and just for fun: CurrentDb.Containers('SysRel').Properties('Permissions').Value"
        Debug.Print CurrentDb.Containers("SysRel").Properties("Permissions").Value
    End Sub
    
    DataAccessPages
       Name = DataAccessPages
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    Databases
       Name = Databases
       Owner = Engine
       UserName = admin
       Permissions =  393216 
       AllPermissions =  393216 
       Inherit = False
    Forms
       Name = Forms
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    Modules
       Name = Modules
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    Relationships
       Name = Relationships
       Owner = Engine
       UserName = admin
       Permissions =  393217 
       AllPermissions =  1048575 
       Inherit = False
    Reports
       Name = Reports
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    Scripts
       Name = Scripts
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    SysRel
       Name = SysRel
       Owner = admin
       UserName = admin
       Permissions =  1048575 
       AllPermissions =  1048575 
       Inherit = True
    Tables
       Name = Tables
       Owner = Engine
       UserName = admin
       Permissions =  1048319 
       AllPermissions =  1048319 
       Inherit = True
    ...and just for fun: CurrentDb.Containers('SysRel').Properties('Permissions').Value
     1048575
    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jan 2008
    Posts
    1

    Cool

    This might be a little late, but in case you are still looking for an answer or if anyone else is looking.

    What has worked for me is using:

    Dim ptsSummaryInfo As DAO.Properties

    instead of:

    Dim ptsSummaryInfo As Properties

    Hope this helps.

    -DatabaseGuy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •