Null v. Zero (1 Viewer)

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
Out of curiosity I have been amusing my self by building a pop up calculator form.

I have noticed that if I set an unbound field to zero (0) value, despite this fact, when the field is interrogated it returns a Null value :confused:

How can I force this field to hold a value of zero rather than Null? Any other values set in the field return their correct value, under identical circumstances.
 

MarkK

bit cruncher
Local time
Today, 01:22
Joined
Mar 17, 2004
Messages
8,179
Do you mean an unbound control? What might be happening, if you handle the Change event of a control, is that the update hasn't occurred yet, so the .Value hasn't changed. You might need to reference the .Text property of the focussed control until AfterUpdate.
Just guessing tho...
Cheers,
 

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
It's an unbound text box.

If I set the value to;
Code:
Me.TextName = "0."
on one button click and the on the next button click use say;
Code:
Me.TextName = Me.TextName & "2"
Me.TextName is showing as holding a Null value rather than literal (0.)
 

MarkK

bit cruncher
Local time
Today, 01:22
Joined
Mar 17, 2004
Messages
8,179
I have code like ...
Code:
Private Sub Command2_Click()
   Me.Text0 = "0."
End Sub

Private Sub Command3_Click()
   Me.Text0 = Me.Text0 & "2"
End Sub
... and I can't cause your result. Am I doing something different? I click Command2 and the Text0 shows "0." and when I click Command3 Text0 shows "0.2". :confused:
 

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
Thanks lagbolt.

I'm thinking that I must have some code that is doing something I've not anticipated :rolleyes: that is preventing the zero value from committing.

I've got to go out for a couple of hours, so perhaps the break will help me spot the problem.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:22
Joined
Sep 12, 2006
Messages
15,634
is the "funny" text box text or numeric?

perhaps it's connected with that.
 

vbaInet

AWF VIP
Local time
Today, 09:22
Joined
Jan 22, 2010
Messages
26,374
Thanks lagbolt.

I'm thinking that I must have some code that is doing something I've not anticipated :rolleyes: that is preventing the zero value from committing.

I've got to go out for a couple of hours, so perhaps the break will help me spot the problem.
The quickest way to spot the problem is to set a Watch and Break when the value is Null or when it changes.
 

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
It was a flaw in my logic in a part of the code designed to deal with a numeric input that followed a, mathematical, operator input :eek:

I knew the break would do me good :D
 

vbaInet

AWF VIP
Local time
Today, 09:22
Joined
Jan 22, 2010
Messages
26,374
:D Good luck with the remainder of the project.

Happy coding John!

NB: By the way, have you started handling divisions by zero? What's the output when it occurs? What's the maximum number of digits on your calculator? How are you handling precision w.r.t decimals? Just curious :)
 

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
All good questions, none of which I have answers for at this point :eek:

The project is really just an exercise in exploring and expanding my coding skills :eek:
 

vbaInet

AWF VIP
Local time
Today, 09:22
Joined
Jan 22, 2010
Messages
26,374
Some points to consider then :)

If you feel up to the task, you could even take it further by building a scientific one too :D

Enjoy!
 

John Big Booty

AWF VIP
Local time
Today, 18:22
Joined
Aug 29, 2005
Messages
8,263
Not until I can get a simple one to add one and one and not get three :p
 

Users who are viewing this thread

Top Bottom