If Statement (1 Viewer)

Gismo

Registered User.
Local time
Today, 07:29
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
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
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 ...
 

Gismo

Registered User.
Local time
Today, 07:29
Joined
Jun 12, 2017
Messages
1,298
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
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
What happens if you

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

I bet you 2p get 0
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
What not even
My Value:

In that case the event isn't firing.
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
I just noticed your using reports.

Try the detail format event.
 

Gismo

Registered User.
Local time
Today, 07:29
Joined
Jun 12, 2017
Messages
1,298
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
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
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.
 

Gismo

Registered User.
Local time
Today, 07:29
Joined
Jun 12, 2017
Messages
1,298
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
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
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.
 

Minty

AWF VIP
Local time
Today, 05:29
Joined
Jul 26, 2013
Messages
10,368
A long integer will never = " " will it?
 

Gismo

Registered User.
Local time
Today, 07:29
Joined
Jun 12, 2017
Messages
1,298
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
 

Gismo

Registered User.
Local time
Today, 07:29
Joined
Jun 12, 2017
Messages
1,298
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

Top Bottom