View Single Post
  #8  
Old December 14th, 2009, 12:20 AM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default If-Then-Else statements

You might need to hide the label also.

What version of Access are you using?
Are you sure the value of PaymentID is NULL?
Is it possible that it is a zero-length string?

You could use something like the following to handle Nulls, zero-length
strings, and strings that consist of multiple spaces.

Me.PaymentID.Visible = Len(Trim(Me.PaymentID & ""))0
Me.PaymentAmount.Visible = Len(Trim(Me.PaymentID & ""))0
Me.PaymentDate.Visible = Len(Trim(Me.PaymentID & ""))0

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

BarbS via AccessMonster.com wrote:
Thank you and the others for helping me try and figure this out.
Obviously I 'm just learning the code, but I've tried all suggestions to no
avail. Maybe I'm not clearly saying what I need to do. I need to suppress
the printing of three controls in a report when the PaymentID control value
is null. The three controls are as you have listed below, PaymentID,
PaymentAmt, and PaymentDate. I'm entering this code in the Report Detail
section, Event, On Format and the three commands and their labels are still
showing on the report (null). Do you have any ideas of what I might be doing
wrong? Again, thank you for your help,

Daniel Pineault wrote:
How about:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Suppress the printing of the Payment Information when the PaymentID
control value is null'
If IsNull([PaymentID]) = True Then
Me.PaymentID.Visible = False
Me.PaymentAmt.Visible = False
Me.PaymentDate.Visible = False
Else
Me.PaymentID.Visible = True
Me.PaymentAmt.Visible = True
Me.PaymentDate.Visible = True
End If
End Sub

I'm presently studying Access and having difficulty understanding building
event codes. What I'm trying to do is suppress the printing of three

[quoted text clipped - 11 lines]
End If
End Sub