I would like to know why it does not work on format in the detail section?
If [Mfrequency] = "Steve" Then [Text32].Visible = True Else [Text32].Visible = False
you can make something look invisible using formatting if you set the foreground and background equal to the sections background. It is not really invisible, but it appears to be.
Continuous forms are multiple instances of a SINGLE form. That single form can have only one set of properties for all visible rows. Therefore, when you do formatting using VBA, it affects ALL visible rows. Conditional formatting was added to overcome this problem. The condition needs to go into the control you want to affect, not the control whose value you want to use.
Continuous forms are multiple instances of a SINGLE form. That single form can have only one set of properties for all visible rows. Therefore, when you do formatting using VBA, it affects ALL visible rows.
Although conditional formatting tends to be an easier and more reliable solution, the above is only partially true. Each row in a continuous form or report is Painted. So you can change the properties between each paint event. This works well on a report, but can be less reliable on a form where you are interacting and continuously causing a repaint event. However the below is done without any conditional formatting. I modified the row where first name = steven. I made the last name appear hidden and painted the email. The trick is you have to set the properties back when the condition is not met.
Code:
Private Sub Detail_Paint()
If Me.First_Name = "Steven" Then
Me.E_mail_Address.BackColor = vbRed
Me.Last_Name.ForeColor = vbWhite
Me.Last_Name.BorderStyle = 0
Else
Me.E_mail_Address.BackColor = vbWhite
Me.Last_Name.FontBold = False
Me.Last_Name.ForeColor = vbBlack
Me.Last_Name.BorderStyle = 1
End If
End Sub
However, if you use the on paint method for your report you still cannot use the visible property. You are stuck with making it appear invisisble.
Although conditional formatting tends to be an easier and more reliable solution, the above is only partially true. Each row in a continuous form or report is Painted. So you can change the properties between each paint event. This works well on a report, but can be less reliable on a form where you are interacting and continuously causing a repaint event. However the below is done without any conditional formatting. I modified the row where first name = steven. I made the last name appear hidden and painted the email. The trick is you have to set the properties back when the condition is not met.
Code:
Private Sub Detail_Paint()
If Me.First_Name = "Steven" Then
Me.E_mail_Address.BackColor = vbRed
Me.Last_Name.ForeColor = vbWhite
Me.Last_Name.BorderStyle = 0
Else
Me.E_mail_Address.BackColor = vbWhite
Me.Last_Name.FontBold = False
Me.Last_Name.ForeColor = vbBlack
Me.Last_Name.BorderStyle = 1
End If
End Sub
No, there is no transparent property for the font. You can write some code to figure out what the alternating color is and set it to that, but that is going to get convoluted. In that case I always do away with the alternate background color.
Potentially you could use an Iff condition in the control
=iiff ([Mfrequency] = "Steve",[mfrequency],Null)
My question is whether the control of interest is visible on a PRINTED or DISPLAYED report. (It makes a difference.) No questions about the fact that it works on a form.