Issues with Null values and .visible

laxster

Registered User.
Local time
Today, 15:47
Joined
Aug 25, 2009
Messages
145
Hi,

I wrote some VBA code which looks at a value in a textbox, and if it's null it will display a blank line.

However, it doesn't work properly with null values, only if I substitute actual values, which I want to avoid if at all possible.

Here's the code:
Code:
If Me.Year = Null Then
  Me.Year.Visible = False
  Me.lnYear.Visible = True
Else
  Me.lnYear.Visible = False
End If

Are there special considerations I should make with null values or a workaround? Again, it works with anything other than a null value, but a null value is what I need it to work for.

Thanks for looking at this! :)
 
Hi,

I wrote some VBA code which looks at a value in a textbox, and if it's null it will display a blank line.

However, it doesn't work properly with null values, only if I substitute actual values, which I want to avoid if at all possible.

Here's the code:
Code:
If Me.Year = Null Then
  Me.Year.Visible = False
  Me.lnYear.Visible = True
Else
  Me.lnYear.Visible = False
End If

Are there special considerations I should make with null values or a workaround? Again, it works with anything other than a null value, but a null value is what I need it to work for.

Thanks for looking at this! :)

I know that null doesn't work well that way.

Try:

Code:
If [COLOR=red]Nz(Me.Year)[/COLOR] Then
  Me.Year.Visible = False
  Me.lnYear.Visible = True
Else
  Me.lnYear.Visible = False
End If
 
It still seems to be doing the same thing. :( Is there a way it will allow me to use the nz function to specify a value, and then use that value to allow the blank line to display and make the text box invisible?
 
It still seems to be doing the same thing. :( Is there a way it will allow me to use the nz function to specify a value, and then use that value to allow the blank line to display and make the text box invisible?

Yeah Something like: Nz(Me.Year,YourValueHere)
 
I am still having issues with it -- I put that right in the code for the OnFormat event, and it refuses to do it properly.

Am I maybe missing something, or is there a better way of doing this?
 
I am still having issues with it -- I put that right in the code for the OnFormat event, and it refuses to do it properly.

Am I maybe missing something, or is there a better way of doing this?

Can you post your db? That was what jumped out at me... I don't know enough, to know what else it could be without playing with is myself.
 
If Me.Year = Null Then

change to

If isnull(Me.Year) Then

Brian

BTW you must display a value with NZ only in the DG of queries does it default to 0.
 

Users who are viewing this thread

Back
Top Bottom