How does the IsNull work??

josie

Registered User.
Local time
Tomorrow, 07:02
Joined
May 17, 2008
Messages
20
I am trying to capture the value of a checkbox on the current report.
I am using the IsNull to try and get around a "Runtime error: 2427 You entered an expression that has no value"
when I use the code;

varPaid = Me!Paid

I am assuming I get this error because sometimes the checkbox isn't ticked??

Anyway, I thought I had it now but the msgbox to get the checkbox value always returns a false - even when the checkbox is ticked.

The code I am using is;

Private Sub Report_Open(Cancel As Integer)
Dim varPaid As Boolean
'check the value
MsgBox varPaid

varPaid = IsNull(Me!Paid)
'check the value again
MsgBox varPaid

If varPaid = False Then
Me.LblPaid.Visible = False
Else
Me.LblPaid.Visible = True
'Me.Section(4).Visible = True

End If

End Sub

What am I not getting (ok, all of it I hear u say <grin>.
josie :o
 
That is because the checkbox value is only null when no value has been specified. One of the many solutions to your current problem would be using:
varPaid = IIf(IsNull(Me!Paid), False, Me!Paid)
 
Try moving your code to the reports "on_format" event.
 
Hmmm....
that doesn't seem to want to work. I get the logic, if me.paid is null then make it false else make it whatever me.paid is.
But now I am back to the original error of "Expression that has no value"
I put the code you suggested as a replacement to the
varPaid = IsNull(Me!Paid)
line - was that what I was supposed to do?
josie
 
Um - can't seem to find the report on_format event.
I've got on open, close, activate, deactive, no data, page & error.
Am I going mad??
josie :confused:
 
I think the issue is that it has no value on the "report_open" event. Move your code to the "on_format" event and see what happens.

The "on_format" event can be found by pulling up the properties in the detail section of the report.
 
thanks forum buddies!
between the alternate iif statement and the move the report I pulled it together.
The code needed to go on the on_activate event to work as I am setting filter criteria from another form.
But the feedback pointed me in exactly the right direction.
much appreciated
josie :)
 
if you have a form with no data (say its a form that doesnt allow additions, but has no data) then everything on the form is UNDEFINED rather then just NULL

if you then try to do a

if nz(somefield,0) this fails because somefield is undefined

you can still error trap it etc, but its not obvious what is happening until youve seen it once.
 

Users who are viewing this thread

Back
Top Bottom