View Full Version : Null Field


Hammy
12-05-2002, 06:41 PM
I have a report that takes it's values froma query. There are 2 address lines allowed int he table. What I want to do is if the second address line is blank in the query, move all the other fields accordingly.

SO I have in the on open event....

If IsNull(Me!address2) Then
Me!City.move left:=2, top:=3
etc,etc for each address field text box

However, no matter what I have my required and allowzerolength fields set to int he table design, address 2 never shows as a null value when blank. If I change the code to check for a blank string (Me![address2textbox]="") then i get an error saying I have entered an expression that has no value.

What am I doing wrong?

Thanks,
Hammy

Ally
12-06-2002, 01:34 AM
Do you mean that if the address field is blank, you want all the other fields to move up into that space?

Others may have easier ways of doing this, but the way I did this once was to join all my fields in one text box, but with IIf statements to say that if the field was null to put the next field in that space. It's longwinded but works.

Example:
address 1 go to new line
address2 go to new line
If address3 is null put nothing, otherwise enter address3, go to new line
If GPTown is null put nothing, otherwise enter GPTown, go to new line etc

=[address1] & Chr(13) & Chr(10) & [address2] & Chr(13) & _
Chr(10) & IIf(IsNull([address3]),"",[address3] & Chr(13) & Chr(10)) _
& IIf(IsNull([gptown]),"",[gptown] & Chr(13) & Chr(10)) & _
IIf(IsNull([gpcounty]),"",[gpcounty] & Chr(13) & Chr(10)) & [gppostcode]

Hammy
12-06-2002, 03:27 AM
Thanks, that works better than my approach! It was getting tedious trying to enter the exact location in the move method. I don't know what was going on there, but not matter what I did it wasn't recognizing the null value. I ended up deleteing the table and re-doing it, and no it does :confused:

I had even trying using a simple IIf(IsNull([address2]),"null","not null") to see how it was seeing it, and it ALWAYS said not null....was driving me NUTS!

Hammy

David R
12-06-2002, 09:15 AM
You might try setting the Can Shrink property in the Format tab of all your address fields. Note of course that this only works on two conditions:

1) Your report is formatted like this:
AddressLine1
AddressLine2
City, etc...

Not AddressLine1, AddressLine2...

2) Fields are not supposed to be 'touching' for Can Shrink to work properly. It can be the smallest bit of space, I believe, but it helps for some reason. Also make sure your entire Detail section is set to Can Shrink.

Good luck,
David R