displaying only true/false values that are true (1 Viewer)

shrndegruv

Registered User.
Local time
Today, 12:57
Joined
Sep 8, 2004
Messages
58
Hi all

I have a form that has twenty True/False items. Rather than display all of them for each record in the DB, how can I show only the ones that are True?

Do I need VB for this? I hope not, but it seems that we can either put the value on the report or not, regardless of true/false...

Thanx in advance.
 

john471

Registered User.
Local time
Tomorrow, 05:57
Joined
Sep 10, 2004
Messages
392
I don't know how you would do this without VB.....

With VB... quite simple !

Assuming :-
*Your form view is Single Form (won't work well at all with "continuous forms")
*You are using checkboxes to display your true/false values, you always want to show them when the bound value is true, and always want to hide them when the bound value is false
*The checkboxes you want to apply this logic to are all named with the same pre-fix e.g. "chk"

If the above assumptions don't hold... you'll need to give more details.

If the above assumptions do hold... set code similar to the following for the Form's OnCurrent event

Code:
Private Sub Form_Current()
    On Error Resume Next
    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Name Like "chk*" Then
            ctl.Visible = ctl.Value
        End If
    Next
    Set ctl = Nothing
End Sub

Now that I've written this, I think I've mis-interpreted your question; given that this is the "reports" forum, and not the "forms" forum. I was going to delete it, but I'll leave it here in case it is helpful.
 
Last edited:
R

Rich

Guest
In the Reports underlying Query, put True in the criteria section of your field
 

shrndegruv

Registered User.
Local time
Today, 12:57
Joined
Sep 8, 2004
Messages
58
very cute rich. But that only affect which records are selected, not which fields are displayed on the report.
 

WayneRyan

AWF VIP
Local time
Today, 20:57
Joined
Nov 19, 2002
Messages
7,122
s,

You can use the DetailFormat event:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim i As Integer
For i = 0 To Me.Controls.Count - 1
   If Me.Controls(i).ControlType = acCheckBox Then
      If Me.Controls(i) Then
         Me.Controls(i).Visible = True
      Else
         Me.Controls(i).Visible = False
      End If
   End If
   Next i
End Sub

Wayne
 

shrndegruv

Registered User.
Local time
Today, 12:57
Joined
Sep 8, 2004
Messages
58
Wayne

thanx that makes some sense. Question: I still have to put the checkboxes on the report -- if one is not visible, is there a space where it is, or does the next visible one take its place? Does that make any sense?

mike
 

WayneRyan

AWF VIP
Local time
Today, 20:57
Joined
Nov 19, 2002
Messages
7,122
Mike,

Yes, that makes sense.

The code just makes them invisible. Their space is still occupied by the
invisible control. You could experiment with Me.YourCheckBox.Left = 1500.
You can move them around, but I don't think it would be worth it.

A nice thing (and easy to try) would be to investigate the color of the
checkboxes.

Me.YourCheckBox.ForeColor & Me.YourCheckBox.BackColor might be nice.
Instead of making them invisible, make them some very light color. They
would still be there for perspective, but the checked ones would really
stand out.

Wayne
 

shrndegruv

Registered User.
Local time
Today, 12:57
Joined
Sep 8, 2004
Messages
58
Wayne

in this case there are so many checkboxes that the report would be ridiculously long if I have to place all of them.

Fortuneately, in this case it makes sense conceptually to divide this report into three reports, limiting the number of chboxes on each report.

It seems like MS needs to make this easier.

Thanx for your insight
m
 

Users who are viewing this thread

Top Bottom