hide a text box based on value of another text box (1 Viewer)

murray83

Games Collector
Local time
Today, 23:08
Joined
Mar 31, 2017
Messages
549
so i have 3 text boxes on my report which are filled in by hand, but on occasion they arent needed and to save confusion with paperwork being reported as incorrect ( as these 3 sections have been missed ) so i have tried the following in the report load but nothing changes

Code:
Private Sub Report_Load()

If Me.Text444.Value = "ALCOHOL FREE" Then
Me.txtJDAComplete.Visible = False
Me.txtDMSProcessed.Visible = False
Me.txtEMCSProcessed.Visible = False
Else
Me.txtJDAComplete.Visible = True
Me.txtDMSProcessed.Visible = True
Me.txtEMCSProcessed.Visible = True
End If


End Sub
so i though that prehaps the text box wasnt being updated or couldnt be read, as the details for the report are pulled into via a query, so then i added another text box and made the new boxes control source Text444 and changed my code as so, and still no dice so any help would be grand, cheers

Code:
Private Sub Report_Load()

If Me.txtARC.Value = "ALCOHOL FREE" Then
Me.txtJDAComplete.Visible = False
Me.txtDMSProcessed.Visible = False
Me.txtEMCSProcessed.Visible = False
Else
Me.txtJDAComplete.Visible = True
Me.txtDMSProcessed.Visible = True
Me.txtEMCSProcessed.Visible = True
End If


End Sub
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
Hi,

Try it in the report's Format event rather than Load.
Code:
Private Sub Report_Format()

  Dim blHide As Boolean

  With Me
    blHide = .txtARC = "ALCOHOL FREE"
    .txtJDAComplete.Visible = blHide
    .txtDMSProcessed.Visible = blHide
    .txtEMCSProcessed.Visible = blHide
  End With

End Sub
hth,

d
 

murray83

Games Collector
Local time
Today, 23:08
Joined
Mar 31, 2017
Messages
549
Hi,

Try it in the report's Format event rather than Load.
Code:
Private Sub Report_Format()

  Dim blHide As Boolean

  With Me
    blHide = .txtARC = "ALCOHOL FREE"
    .txtJDAComplete.Visible = blHide
    .txtDMSProcessed.Visible = blHide
    .txtEMCSProcessed.Visible = blHide
  End With

End Sub
hth,

d
thanks for the tip, but sorry to say it didnt work 100% as it removed the 3 boxes for each occurence not just when it was ALCOHOL FREE

This is what i posted for the code

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  Dim blHide As Boolean

  With Me
    blHide = .txtARC = "ALCOHOL FREE"
    .txtJDAComplete.Visible = blHide
    .txtDMSProcessed.Visible = blHide
    .txtEMCSProcessed.Visible = blHide
  End With
End Sub
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
Are all those controls on the detail section of the report?
 

murray83

Games Collector
Local time
Today, 23:08
Joined
Mar 31, 2017
Messages
549
Text444 is the one above which just states ARC in it
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
What happens if you change to:
Code:
' ...
    blHide = .Text444 = "ALCOHOL FREE"
' ...
 

murray83

Games Collector
Local time
Today, 23:08
Joined
Mar 31, 2017
Messages
549
same thing, i placed the dim like so

Code:
Option Compare Database
  Dim blHide As Boolean



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

  With Me
    blHide = .Text444 = "ALCOHOL FREE"
    .txtJDAComplete.Visible = blHide
    .txtDMSProcessed.Visible = blHide
    .txtEMCSProcessed.Visible = blHide
  End With

End Sub
but can i ask why this way, why not a if or else, not that im doubting your knowlegde just curious to why this solouton
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
Ignore all that!

Change to:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  Dim blVisible As Boolean

  With Me
    blVisible = .txtARC <> "ALCOHOL FREE"
    .txtJDAComplete.Visible = blVisible
    .txtDMSProcessed.Visible = blVisible
    .txtEMCSProcessed.Visible = blVisible
  End With
End Sub
Doh! :oops:
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
Yes, if else is fine, just more typing...

... but probably safer, since you are less likely to get the logic messed up like I did!
 

murray83

Games Collector
Local time
Today, 23:08
Joined
Mar 31, 2017
Messages
549
ill give it a go and see what happens

do i need to place the dim at the top or can it be inside the sub ?
 

cheekybuddha

AWF VIP
Local time
Today, 23:08
Joined
Jul 21, 2014
Messages
389
Inside the sub.

The code is the equivalent of:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

  With Me
    If .Text444 <> "ALCOHOL FREE"
      .txtJDAComplete.Visible = True
      .txtDMSProcessed.Visible = True
      .txtEMCSProcessed.Visible = True
    Else
      .txtJDAComplete.Visible = False
      .txtDMSProcessed.Visible = False
      .txtEMCSProcessed.Visible = False
    End If
  End With

End Sub
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom