Nz function sounds good but really I want more than a number or a string.

G

George Hester

According to this page:

http://support.microsoft.com/kb/295619/en-us

Microsoft says the IsNull(fax.value) will evaluate to False when fax.value =
Null. Well it's a good thing I didn't bother to read that article until afer
I started using IsNull.

I have some fields in a database that are sparsely populated. I wanted to
make sure the Child_Labels in the Text box that is to display those fields
stayed invisible when there was nothing for the field value. So I used
IsNull and have been chugging merrily away using it. Until I read this
article. Now I am not sure why what they say doesn't work. Is this true for
Nz in a DAP? Is it always true? I don't get it. Maybe someone does?

I am accepting to try the Nz workaround since what I been using "doesn't
work." But consider the restrictions of this function. We can only replace a
variable that is Null with a value which isn't. Of course I want my Null
values to stay Null. I just want to hide the controls that are not showing
the field with the Null value. So how can I use Nz to do this? Something
like:

Nz(MSDOC.DefaultRecordSet.Fields("Field1").Value,document.all.item("Text0").
style.visibility = "hidden")
Nz(MSDOC.DefaultRecordSet.Fields("Field1").Value,document.all.item("Text0_Ch
ildLabel").style.visibility = "hidden")

I doubt that will work better than:

If IsNull(MSDOC.DefaultRecordSet("Field1").Value) Then
document.all.item("Text0").style.visibility = "hidden"
document.all.item("Text0_ChildLabel").style.visibility = "hidden"
Else
document.all.item("Text0").style.visibility = "visible"
document.all.item("Text0_ChildLabel").style.visibility = "visible"
End If

And yes this does work. But I would like to try the workarounds using Nz as
Microsoft says to achieve the above.
 
J

John W. Vinson

According to this page:

http://support.microsoft.com/kb/295619/en-us

Microsoft says the IsNull(fax.value) will evaluate to False when fax.value =
Null.

.... using Access 2002. Not other versions.
Well it's a good thing I didn't bother to read that article until afer
I started using IsNull.

I have some fields in a database that are sparsely populated. I wanted to
make sure the Child_Labels in the Text box that is to display those fields
stayed invisible when there was nothing for the field value. So I used
IsNull and have been chugging merrily away using it. Until I read this
article. Now I am not sure why what they say doesn't work. Is this true for
Nz in a DAP? Is it always true? I don't get it. Maybe someone does?

This was a bug in one version. It's been fixed.
I am accepting to try the Nz workaround since what I been using "doesn't
work."

This was a bug in one version. It's been fixed.
And yes this does work. But I would like to try the workarounds using Nz as
Microsoft says to achieve the above.

Reread the article, in particular the "Applies To".

John W. Vinson [MVP]
 
T

Terry Kreft

You've got the choice of using an obscure non-supported bug or using
supported clear code and you want to use the bug?

Go with the code, it's easier to read and in a years time when you have to
revisit it you won't be wondering how these controls are getting hidden.

If you have to upgrade from the bugged version you wont have to revisit the
form to do this properly.

Just use code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top