Make Text Box Invisible

Stemdriller

Registered User.
Local time
Today, 18:48
Joined
May 29, 2008
Messages
187
Hi All

I am trying to get a report to make either one of two text boxes invisible depending on the users input.

So if txt15 is blank then visible = FALSE this should then reveal txt18 which should then have data in.

I have looked through the forum and found something similar to the following.

Private Sub FormHeader_Format(Cancel As Integer, FormatCount As Integer)

Me.Txt15.Visible = Not IsNull(Me.Txt15)
Me.Txt18.Visible = Not IsNull(Me.Txt18)

It works to a degree, but if txt15 is Blank it does not make the textbox invisible thus will not display Txt18

Any help would be appreciated.

Thanks

Gareth
 
You're going to need a If Then Statement, something like...

If Not IsNull(Me.Txt15) Then
Me.Txt15.Visible = True
Me.Txt18.Visible = False
Else
Me.Txt15.Visible = False
Me.Txt18.Visible = True
End If
 
Is there any way to do this where instead of hiding the text box when the field is empty, to hiding it when a date falls outside of a set range? I've tried changing it using 'Between' and with < and > but I keep getting errors.

The reason for this is I've got information under 4 different dates relating to the quarter of the year, but I only want to show information fpr the previous and next quarter.
 
Last edited:
No need for two textboxes. One will suffice:

For e.g., if

Control Source of txt15 is Date15
Control Source of txt18 is Date18

Set the control source of txt15 to
Code:
=IIF([[COLOR=Blue]Date15[/COLOR]] >= [[COLOR=DarkGreen]SomeDate[/COLOR]] And [[COLOR=Blue]Date15[/COLOR]] <= [[COLOR=DarkGreen]SomeDate[/COLOR]], [[COLOR=Blue]Date15[/COLOR]], [[COLOR=Red]Date18[/COLOR]])
 
I've possibly not explained myself properly or should've started a new thread instead of hijacking this one.

There are a series of projects and once the project ends they should develop action plans for the future. These need to be monitored quarterly over the following 12 months. In my table I have different dates for each quarter that is calculated from the date entered for the completion of the project, and then a corresponding field showing the progress made. On my report I would like to show only the relevant information for that time (the previous/next quarter). My query filters out all records that aren't relevant for any of the 4 dates so I need to use code to make the irrelvant text boxes invisible. So far I have got the following to try and show only dates for the months of June-August:

If Me.Quarter_1_Date.Value < 1 / 6 / 2011 And Me.Quarter_1_Date.Value > 30 / 8 / 2011 Then
Me.Quarterly_1_Update_Progress.Visible = False
ElseIf Me.Quarterly_1_Date.Value > 1 / 6 / 2011 And Me.Quarterly_1_Date.Value > 30 / 8 / 2011 Then
Me.Quarterly_1_Update_Progress.Visible = True
End If

This is either showing all of the info for the 1st date or none of it depending which way round I write it. Makes me think (hope) that it's something simple.

Any help massively appreciated.
 
Last edited:
So you just want to hide it when it doesn't fall within the range? Just set it to Null if it's outside the range. Set this as the Control Source property of the textbox:
Code:
=IIF([[COLOR=Red]Quarter_1_Date[/COLOR]] < "1/6/2011" And [[COLOR=Red]Quarter_1_Date[/COLOR]] > "30/8/2011", Null, [[COLOR=Red]Quarterly_1_Update_Progress[/COLOR]]))

By the way your criteria here is incorrect. Reconsider your criteria:
ElseIf Me.Quarterly_1_Date.Value > 1 / 6 / 2011 And Me.Quarterly_1_Date.Value > 30 / 8 / 2011 Then
 
Thanks for your help. I tried putting that in the control source but now it just shows #error. I tried it directly as it is as well as "" instead of null. Any more ideas?
 
Fixed it!

It was because it was using itself in the expression so I just done some extra text boxes with the original data, but turned visible to no in the properties. Thanks again!
 
Fixed it!

It was because it was using itself in the expression so I just done some extra text boxes with the original data, but turned visible to no in the properties. Thanks again!
Your choice ;) You were given a much more elegant solution.

At least it works for you.
 

Users who are viewing this thread

Back
Top Bottom