Dynamically positioning groups of controls

briancross

New member
Local time
Today, 18:12
Joined
Sep 1, 2009
Messages
7
I am currently building a report, however I am running into a roadblock that is stopping me from reaching my desired result.

Each record in the detail section of my report has a standard tabular section (with column names in the report header). Below that are three more groups of controls that are shown dependent on the data (ie - there are several controls related to a boolean field named TRR_required. If TRR_required is false all these items are hidden). I would like to only display these groups if the required field is true. I have successfully been able to hide the controls by setting Visible = false for the appropriate controls, however this simply leaves a blank area in the detail section for each record. Using me.detail.autoheight = true causes Access to crash when trying to render the report in print preview view.

Here is what I have for code on detail_format:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    If Me.PSRR_req.Value = False Then
        With Me
            .PSRR_req.Visible = False
            'related controls also marked visible = false
        End With
    Else
        With Me
            .PSRR_req.Visible = True
            'related controls also marked visible = true
        End With
    End If
    
    If Me.TRR_req.Value = False Then
        With Me
            .TRR_req.Visible = False
            'related controls also marked visible = false
        End With
    Else
        With Me
            .TRR_req.Visible = True
            'related controls also marked visible = true
        End With
    End If
    
    If Me.Comments.Text = "" Then
        With Me
            .Comments.Visible = False
            .Label27.Visible = False
        End With
    Else
        With Me
            .Comments.Visible = True
            .Label27.Visible = True
        End With
    End If
   
    'Me.Detail.AutoHeight = True
                  
End Sub

I have a feeling I'm missing something simple, but any help at all would be greatly appreciated!
 
me.detail.autohight i don't think will do anything, as your extra controls are record specific rather than section specific. this might be impossible to get right, but do the controls have to be included with every record? if so, maybe you could display some sort of n/a data in the controls if you want to be invisible. that way your report would seem uniform, even though it may take up more space than you desire.

other options may be popup boxes for the information, depending on the need for the info display on either report viewing, printing, or both. also, it may not mean anything, but remember there are properties called display, and the options are print preview, print only, or both (i think). that may be relevant here too...
 
I've been looking into this for a few days now and haven't come across an easy solution (or any for that matter). These controls do not need to be included with each record. There are 3 groups: PSRR, TRR and Comments. PSRR and TRR (both review meetings, that may or may not be required for each item) have a couple date fields, a couple text fields and two bool fields. If the TRR/PSRR_req (required) field is false, then I do not want to show any of the other data, even if it is there in the source table. I can hide it using the code in the OP, but that does just that...hides it...leaving a big empty space on my report. Same rules apply to comments, but if there are no comments I don't want to show anything, including the comments label.

The only solution I can think of is to position each object at runtime with VBA, but I would have to consider each of 9 possible combinations of show/hide for each fo the three items. Considering the small scope of this particular project, that would put this problem in the too hard pile.
 

Users who are viewing this thread

Back
Top Bottom