Checking if SourceObject has no records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Breezwell
    New Member
    • Sep 2008
    • 33

    Checking if SourceObject has no records

    First off, let me say that this forum has provided me with numerous guidance to Access programming challenges I have faced while learning, and I am grateful to all those who share thier knowledge with others.

    My current question involves SourceObjects. I have a form that has three SourceObjects, each of which displays the results of a query designed just for that particular SourceObject. Each SourceObject will reaveal information from a table that also supports just that particular SourceObject.

    For example....

    Table1 = SourceObject1
    Table2 = SourceObject2
    Table3 = Source Object3

    After the queries run, each SourceObject is revealed on a form with the visible property set to True. Basically, I would like to only show SourceObjects that have actual data in them based on the current query. So, if only Table1 data is returned, I only want to show SourceObject1.

    Is there a way to check if a SourceObject is empty and only include it on the form if it holds data?

    Thanks for any replies and I can try to clarify further if need be.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    After the queries run, each SourceObject is revealed on a form with the visible property set to True.
    I'm a little confused on exactly what you mean by this, please clarify the above statement, and also explain exactly what you mean by 'SourceObject'.

    Comment

    • Breezwell
      New Member
      • Sep 2008
      • 33

      #3
      Originally posted by ADezii
      I'm a little confused on exactly what you mean by this, please clarify the above statement, and also explain exactly what you mean by 'SourceObject'.
      Thanks for the reply ADezzi.
      I am a little confused as well, so I guess it is showing in my descriptions.

      Basically I have a single form with three subforms attached in a hidden state. Each subform has its SourceObject property set to a unique query.

      For example, Me.AuditQueryNA .SourceObject = "query.AuditQue ry"

      All three queries run when a single button is clicked. I would like to somehow reveal, or include on the page ideally, only those subforms that have data in the SourceObjects query result set.

      I am thinking this would require some conditional checking on the query result set or SourceObject property?

      Hope this makes more sense.

      Thanks

      Comment

      • Breezwell
        New Member
        • Sep 2008
        • 33

        #4
        Okay, with a little digging, and this site nonetheless, I found a solution posted by Trevor Best that I modified slightly.

        Basically the solution involves putting the subform reference in a conditional that utilizes the DCount funtion to inspect the queries results:

        I first assinged the query to the subforms SourceObject and then checked the queries resultset. Works perfectly.

        Me.AuditQueryFT OSubform.Source Object = "query.AuditQue ry3"
        If DCount("*", "AuditQuery 3") = 0 Then
        Me.AuditQueryFT OSubform.Visibl e = False
        Else
        Me.AuditQueryFT OSubform.Visibl e = True
        End If

        Hope this helps someone else down the road.

        Comment

        Working...