Unbound Text Box = 0 in Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ElTipo
    New Member
    • Jul 2007
    • 36

    Unbound Text Box = 0 in Form

    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:
    Code:
    If Me.[Datefield].Value <> Null And Me.[Datefield].Value <> Null Then
    Me.[Resulttextbox].Value = 0.5
    Any Help?
    Last edited by NeoPa; Oct 15 '09, 10:27 PM. Reason: Please use the [CODE] tags provided.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by ElTipo
    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?
    Code:
    If Not IsNull(Me!<[Field1]>) And Not IsNull(Me!<[Field2]>]) Then
      MsgBox "Both not Null"
    End If

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      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

      Comment

      • ElTipo
        New Member
        • Jul 2007
        • 36

        #4
        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:
        Code:
        If IsNull(Me![Datefield1]) And Not IsNull(Me![Datefield2]) Then
        Me.[ResultTextbox].Value = 1
         Else
        If Not IsNull(Me![Datefield3]) And Not IsNull(Me![Datefield4]) Then
        Me.[ResultTextbox].Value = 0.5
         Else
        Me.[ResultTextbox].Value = 0
        The result has to see where I place the event procedure?
        Ex: on OpenForm etc..
        Last edited by NeoPa; Oct 16 '09, 11:08 PM. Reason: Please use the [CODE] tags provided.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          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.

          Comment

          Working...