If Statement

Gismo

Registered User.
Local time
Today, 15:15
Joined
Jun 12, 2017
Messages
1,298
Hi all,

If non of the below if statements work, what else could I look at?

Private Sub Report_Current()
'If IsNull(Me.ADHOC) Then
If Me.ADHOC = " " Then
'If Me.ADHOC <> 0 Then
Me.AdHocLbl.Visible = False
Else
Me.AdHocLbl.Visible = True
End If
End Sub
 
What type of data is ADHOC?
One of the more reliable ways to check for null or empty strings is to use

If Len(Me.ADHOC & "") = 0 Then ...
 
What type of data is ADHOC?
One of the more reliable ways to check for null or empty strings is to use

If Len(Me.ADHOC & "") = 0 Then ...
ADHOC is a Long Integer

Above code does not give the desirable outcome either

1647427077187.png
 
What happens if you

Debug.print "My Value: " & me.ADHOC

I bet you 2p get 0
 
What not even
My Value:

In that case the event isn't firing.
 
I just noticed your using reports.

Try the detail format event.
 
I just noticed your using reports.

Try the detail format event.
Still no luck

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Len(Me.ADHOC & "") = 0 Then
Me.AdHocLbl.Visible = False
Else
Me.AdHocLbl.Visible = True
End If
End Sub
 
Again add back in the debug to see if the event is even firing.
Printing off the value will give you a proper indication of what is happening and what the value is.
 
Again add back in the debug to see if the event is even firing.
Printing off the value will give you a proper indication of what is happening and what the value is.
no result with debug.print
 
So the event isn't firing then.
Why not make a calculated field in the underlying query.

MyADHOC : IIf([ADHOC] = 0, Null, "ADHOC : " & [ADHOC])

Then make a control on the report to hold it.
 
A long integer will never = " " will it?
 
So the event isn't firing then.
Why not make a calculated field in the underlying query.

MyADHOC : IIf([ADHOC] = 0, Null, "ADHOC : " & [ADHOC])

Then make a control on the report to hold it.
Sorry, send the message just as your comment came through
 
The data type is long integer
The data comes from a pivot table, all data refers to long integer

I am having the same issue on a report to make the border of a control transparent when no data and this is a text

Private Sub Report_Current()
If IsNull(Me.Description) Then
Me.Description.BorderStyle = 0
End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom