View Full Version : Default Value


lead 27
09-20-2007, 01:00 PM
Hi

I have a number field which controls a yes/no box (basically if the number is greater than 0 the box is ticked). However I have just discovered a problem, if the user just deletes the number rather than putting a 0 in teh box it wont change my yes/no field to no.

How can I have it so that if there is nothing in the box 0 is displayed? I tried Default value but couldnt get it to work.

Thanks

pbaldy
09-20-2007, 01:05 PM
Why have the yes/no field at all? It is basically a calculated value, and the problem you're having is why it's recommend to not store calculated values. You could simply use an IIf in queries, forms or reports that examines the number field and returns yes/no or whatever you want. In any case, you could put code in the after update event of the control containing the number field and set the checkbox accordingly.

lead 27
09-20-2007, 01:14 PM
Hi
thanks for replying. The code that I have already on the after update event is:
If Me.QTY1 > 0 Then
ON_DEMAND = True
End If
If Me.QTY1 < 1 And QTY2 < 1 Then
ON_DEMAND = False
End If

This works fine unless there is no number in the box.

pbaldy
09-25-2007, 09:15 AM
Sorry for the delay; I have been out of town. Did you get this resolved? For an empty control, you need to test for Null and ZLS:

If Nz(Me.QTY, "") = "" Then

lead 27
09-25-2007, 12:58 PM
Hi
All that I have done is made the field required that way they have to input a number so hopefully they will use their common sense

Thanks for following up