Question : Subdatasheet behavior

Hello - I have a set of Subdatasheet queries, nested 4 levels deep (Access 2003). It usually works fine, but sometimes the "+"'s do not appear on a given level as I am drilling down. I usually just close the top-level query, re-open it, and it works fine after that.

Here lately, the "+"'s do not appear on the 2nd level the first time I drill down from the first level. I close the 1st level qry, re-open it, and it works fine.

What's the deal here? is there some trick to making these things behave consistently? (preferably, correctly...)

Thanks

Answer : Subdatasheet behavior

According to Allen Browne, the subdataseet name property is a problem in ms access and should be turned off.  (Subdatasheet Name property set to [Auto] should be [None].)  See this link, excerpted below:      http://allenbrowne.com/bug-09.html

I believe the subdatasheets will still function on the basis of the master and child links even though the subdatasheet name property has been turned off.  As always, make sure you have adequate backups before making any changes.
__________________________________________________________________
Tables: SubdatasheetName
In Access 2000, tables got a new property called SubdatasheetName. If the property is not set, it defaults to "[Auto]". Its datasheet displays a plus sign which the user can click to display related records from some other table that Access thinks may be useful.

This automatically assigned property is inherited by forms and subforms displayed in datasheet view. Clearly, this is not a good idea and may have unintended consequences in applications imported from earlier versions. Worse still, there are serious performance issues associated with loading a form that has several subforms where Access is figuring out and collecting data from multiple more related tables.

Again, the solution is to turn off subdatasheets by setting the property to "[None]". Again, there is no way to do this by default, so you must remember to do so every time you create a table. This code will loop through your tables and turn the property off:

Function TurnOffSubDataSh()
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim prp As DAO.Property
    Const conPropName = "SubdatasheetName"
    Const conPropValue = "[None]"
   
    Set db = DBEngine(0)(0)
    For Each tdf In db.TableDefs
        If (tdf.Attributes And dbSystemObject) = 0 Then
            If tdf.Connect = vbNullString And Asc(tdf.Name) <> 126 Then 'Not attached, or temp.
                If Not HasProperty(tdf, conPropName) Then
                    Set prp = tdf.CreateProperty(conPropName, dbText, conPropValue)
                    tdf.Properties.Append prp
                Else
                    If tdf.Properties(conPropName) <> conPropValue Then
                        tdf.Properties(conPropName) = conPropValue
                    End If
                End If
            End If
        End If
    Next
   
    Set prp = Nothing
    Set tdf = Nothing
    Set db = Nothing
End Function

Public 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
Random Solutions  
 
programming4us programming4us