Feb 19 2022 06:26 AM
Hello Experts,
I have been trying to get this one field on my report to turn visible on and bring to front if another field is Null or "".
The below is what I have and it doesnt seem to do anything. The field names are correct.
I also need to add (I think):
DoCmd.RunCommand acCmdBringToFront
DoCmd.RunCommand acCmdSendToBack
Where have I made the mistake?
thank you
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtAcctNo, 0) = "" Then
Me.txtAcctNoFront.Visible = True
Else
Me.txtAcctNoFront.Visible = False
End If
End Sub
Feb 19 2022 07:39 AM
One obvious problem is with the Nz expression
If its a text field, use:
If Nz(Me.txtAcctNo, "") = "" Then
but if its a number field, then you need
If Nz(Me.txtAcctNo, 0) = 0 Then
Form your description, your field is normally hidden so you can place it at the front in design view. No need to shift from back to front.
As its normally hidden the else part is superfluous, so you can simplify to (assuming a number field):
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtAcctNo, 0) = 0 Then Me.txtAcctNoFront.Visible = True
End Sub
Feb 19 2022 10:30 AM
Feb 19 2022 01:36 PM
SolutionFormat events only work in Print Preview
Can't see anything obvious that's wrong....
Are both controls on the detail section?
Try the opposite logic. Make txtAcctNoFront visible by default then use this code
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtAcctNo, "") <> "" Then Me.txtAcctNoFront.Visible = False
End Sub
Feb 19 2022 03:59 PM
Feb 20 2022 12:18 AM
Feb 19 2022 01:36 PM
SolutionFormat events only work in Print Preview
Can't see anything obvious that's wrong....
Are both controls on the detail section?
Try the opposite logic. Make txtAcctNoFront visible by default then use this code
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtAcctNo, "") <> "" Then Me.txtAcctNoFront.Visible = False
End Sub