Hide report control if date eq (1 Viewer)

foshizzle

Registered User.
Local time
Today, 14:29
Joined
Nov 27, 2013
Messages
277
Is it possible to hide a report control based on a date?

On this report, I have two text controls in the report detail: txtTransactionDate and txtGainLoss
I only want to show the txtGainLoss control if txtTransactionDate (report date) is the last day of the month. I'm not sure its possible because we export all reports to PDF and do not show the report itself in acView... If it is possible, I'm not sure where to initiate the code, or if this is correct.

I've hidden the txtGainLoss control in detail view and trying to set it to visible when the report is printed.This is what I have so far.

Private Sub Report_Open(Cancel As Integer)
If Me.txtTransactionDate.Value = DateSerial(Year(Date), Month(Date) + 1, 0) Then
Me.txtGainLoss.Visible = True
End If
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:29
Joined
Sep 21, 2011
Messages
14,046
No good in the Open event, the value of TransactionDate is going to change, surely?
I would have thought you would want it in the equivalent of a Form Current event? On Format or On Print of the Detail section?
I also think you would have to hide/show on each test?
 

foshizzle

Registered User.
Local time
Today, 14:29
Joined
Nov 27, 2013
Messages
277
No good in the Open event, the value of TransactionDate is going to change, surely?
I would have thought you would want it in the equivalent of a Form Current event? On Format or On Print of the Detail section?
I also think you would have to hide/show on each test?
I've tried both of these in the detail section of the report with no luck. I don't get an error or anything. I've tried placing a message box to pop up as well to verify something is happening using "MsgBox Me.txtTransactionDate.Value" but nothing happens.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:29
Joined
Sep 21, 2011
Messages
14,046
Best wait for an expert then.
 

foshizzle

Registered User.
Local time
Today, 14:29
Joined
Nov 27, 2013
Messages
277
ok - ive found a work around. thanks anyway!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:29
Joined
Feb 19, 2002
Messages
42,971
For future reference, the detail section's on Format event would be the event for that code. OR you could use conditional formatting.
 

Users who are viewing this thread

Top Bottom