Connecting Tech Pros Worldwide Help | Site Map

Unbound Text Box = 0 in Form

Member
 
Join Date: Jul 2007
Posts: 32
#1: Oct 15 '09
Great People!

I need some help in this instruction. Ok I have two fields text boxes dates and one text box showme any result but the result text box only show me a zero 0 as result. I need in this result 0.5 if the two fields are Not Null.

All this is in VBA in a Form nested If with the same instructions but other results example 0.75 or 1.

Ex:
Expand|Select|Wrap|Line Numbers
  1. If Me.[Datefield].Value <> Null And Me.[Datefield].Value <> Null Then
  2. Me.[Resulttextbox].Value = 0.5
Any Help?
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,213
#2: Oct 15 '09

re: Unbound Text Box = 0 in Form


Quote:

Originally Posted by ElTipo View Post

Great People!

I need some help in this instruction. Ok I have two fields text boxes dates and one text box showme any result but the result text box only show me a zero 0 as result. I need in this result 0.5 if the two fields are Not Null.

All this is in VBA in a Form nested If with the same instructions but other results example 0.75 or 1.

Ex:

If Me.[Datefield].Value <> Null And Me.[Datefield].Value <> Null Then
Me.[Resulttextbox].Value = 0.5

Any Help?

Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me!<[Field1]>) And Not IsNull(Me!<[Field2]>]) Then
  2.   MsgBox "Both not Null"
  3. End If
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#3: Oct 15 '09

re: Unbound Text Box = 0 in Form


As the Null value is neither numeric nor textual, it cannot be compared as a number or text.

ADezii's post shows how controls can be tested for Null.

BTW your code tries to test the same control twice :S
Member
 
Join Date: Jul 2007
Posts: 32
#4: Oct 16 '09

re: Unbound Text Box = 0 in Form


Thanks ADezii for your time the sintax work but only showme the first line result (1) for this nested IF and not change for the second IF situation.

Ex:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me![Datefield1]) And Not IsNull(Me![Datefield2]) Then
  2. Me.[ResultTextbox].Value = 1
  3.  Else
  4. If Not IsNull(Me![Datefield3]) And Not IsNull(Me![Datefield4]) Then
  5. Me.[ResultTextbox].Value = 0.5
  6.  Else
  7. Me.[ResultTextbox].Value = 0
The result has to see where I place the event procedure?
Ex: on OpenForm etc..
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#5: Oct 17 '09

re: Unbound Text Box = 0 in Form


Could you post the results you get along with the values in the four datefield controls. Please also include the reults that you would expect where different from those seen. That way we can check what is and what isn't working.

PS. Please note the edit comments by some of your posts. As a full member now you need to be more careful of the rules. We tend to be more lenient with Newbies.
Reply