how to make label visible depending on text box value

sspreyer

Registered User.
Local time
Today, 09:00
Joined
Nov 18, 2013
Messages
251
hi
all

right ....

I have a report that displays on a continuous style report. What courses the employee have been on and when they expire

right I have field call expirydate and another call dayover showing the number of days till that course has expired also I have made a label called Expired1

now what I'm trying to do.....

if the expirydate has passed I want the expired1 label to be visible and dayover field to become invisible

I have tried

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
 If Me.Expirydate < Date Then
Me.expired1.Visible = True
Me.DaysOver.Visible = False
End If
If Me.Expirydate > Date Then
Me.expired1.Value = False
Me.DaysOver.Value = True
End If
I have also tried the code on current event on the report


now my problem

if one of the course has expired it will show the label called Expired1 but on all the records but I only want it to display on the record that has expired and leave the daysover text box visible if course has not expired

hope you understand


thanks in advance

shane
 
1. Change the label to a Textbox
2. Put the code in the Control Source in this format:
Code:
=IIF([[COLOR="blue"]Expirydate[/COLOR]] < Date(), "[COLOR="Blue"]Caption goes here[/COLOR]", Null)
3. Set the Can Grow and Can Shrink properties to Yes.

By the way, your condition doesn't cater for when Expirydate = Date().
 
THANKS!!!!! Vbainet worked a Treat:D:D only one more question how can I make the dayover Textbox invisible if the expiry date has passed and only on the records that have passed

cheers

shane
 
THANKS!!!!! Vbainet worked a Treat:D:D only one more question how can I make the dayover Textbox invisible if the expiry date has passed and only on the records that have passed
Shane I don't understand that part. In any case, your original code included the DayOver field in there so I guess you can use the same code but switch the conditions.

By the way, did you pay attention to this comment?
By the way, your condition doesn't cater for when Expirydate = Date().
 
THANKS!!!!! Vbainet worked a Treat:D:D only one more question how can I make the dayover Textbox invisible if the expiry date has passed and only on the records that have passed

hi ,
Vbaineti

god knows what I was going on about hadn't had much sleep!!!!

after reading your last post again!! today and a little more awake and fresh eyed :)

I got the logic behind it

In any case, your original code included the DayOver field in there so I guess you can use the same code but switch the conditions.

so I removed daysover field and done it by unbound text box using control with

Code:
=IIf([Expirydate]>Date(),DateDiff("d",Date(),[Expirydate]))
so the daysover will only display if the date is +
and now works lovely

thanks again vbainet for putting up with me:(

cheers

shane
 
so I removed daysover field and done it by unbound text box using control with

Code:
=IIf([Expirydate]>Date(),DateDiff("d",Date([COLOR="Red"]),[Expirydate])[/COLOR])
Good to know that you're not saving calculated values, but... are you sure your code is correct? I've highlighted parts of the code that's missing (or has one too many) closing parentheses within.
 
Good to know that you're not saving calculated values, but... are you sure your code is correct? I've highlighted parts of the code that's missing (or has one too many) closing parentheses within.

It's exactly like that and working :confused:
Oh well

Thanks

Shane
 
The third parameter is not optional. You only have two parameters.
What's the code supposed to mean anyway? Say it in words and I'll fix it.
 

Users who are viewing this thread

Back
Top Bottom