ComboBox (Null value variable error)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg (codepug@gmail.com)

    #1

    ComboBox (Null value variable error)

    Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
    'Delete combobox entry if Del or Backspace key is hit.
    If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
    End Sub

    I have used identical code in the KeyDown event of my other comboboxes
    to clear the box when
    the delete or backspace key is pressed. It works for many identical
    comboboxes just fine except
    for the cboBody combo. I have looked this over and cannot find any
    differences in the combobox's that are working ans the one that is
    not I get the following error message?

    Error: "You tried to assign the Null value to a variable that is not a
    Variant data type"

    Is the combobox a variable? Any ideas?

  • JvC

    #2
    Re: ComboBox (Null value variable error)

    Your combo box is bound to a field in the database. The field won't
    accept null values. You need to go into the table design, and allow the
    field to allow nulls.

    John

    reg (codepug@gmail. com) formulated the question :
    Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
    'Delete combobox entry if Del or Backspace key is hit.
    If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
    End Sub
    >
    I have used identical code in the KeyDown event of my other comboboxes
    to clear the box when
    the delete or backspace key is pressed. It works for many identical
    comboboxes just fine except
    for the cboBody combo. I have looked this over and cannot find any
    differences in the combobox's that are working ans the one that is
    not I get the following error message?
    >
    Error: "You tried to assign the Null value to a variable that is not a
    Variant data type"
    >
    Is the combobox a variable? Any ideas?

    Comment

    • Greg (codepug@gmail.com)

      #3
      Re: ComboBox (Null value variable error)

      Thanks JvC

      But my other combo boxes are working. And, yes you are correct they
      are bound to a Tables field, but I do not
      see, in table design, where I would allow a field to accept null
      values? The field by the way is LongInteger as is the case
      in the other comboboxes that are working.

      Thanks Greg


      On Jul 25, 3:12 pm, JvC <johnv...@earth link.netwrote:
      Your combo box is bound to a field in the database. The field won't
      accept null values. You need to go into the table design, and allow the
      field to allow nulls.
      >
      John
      >
      reg (code...@gmail. com) formulated the question :
      >
      >
      >
      Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
         'Delete combobox entry if Del or Backspace key is hit.
          If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
      End Sub
      >
      I have used identical code in the KeyDown event of my other comboboxes
      to clear the box when
      the delete or backspace key is pressed.  It works for many identical
      comboboxes just fine except
      for the cboBody combo.  I have looked this over and cannot find any
      differences in the combobox's that are working ans the one that is
      not         I get the following error message?
      >
      Error: "You tried to assign the Null value to a variable that is not a
      Variant data type"
      >
      Is the combobox a variable?  Any ideas?- Hide quoted text -
      >
      - Show quoted text -

      Comment

      • JvC

        #4
        Re: ComboBox (Null value variable error)

        Greg,

        Strange! You can't ever assign a null to a long integer. Try setting
        cboBody to 0, and see if that works.

        John

        Greg (codepug@gmail. com) used his keyboard to write :
        Thanks JvC
        >
        But my other combo boxes are working. And, yes you are correct they
        are bound to a Tables field, but I do not
        see, in table design, where I would allow a field to accept null
        values? The field by the way is LongInteger as is the case
        in the other comboboxes that are working.
        >
        Thanks Greg
        >
        >
        On Jul 25, 3:12 pm, JvC <johnv...@earth link.netwrote:
        >Your combo box is bound to a field in the database. The field won't
        >accept null values. You need to go into the table design, and allow the
        >field to allow nulls.
        >>
        >John
        >>
        >reg (code...@gmail. com) formulated the question :
        >>
        >>
        >>
        >>Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
        >>   'Delete combobox entry if Del or Backspace key is hit.
        >>    If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
        >>End Sub
        >>
        >>I have used identical code in the KeyDown event of my other comboboxes
        >>to clear the box when
        >>the delete or backspace key is pressed.  It works for many identical
        >>comboboxes just fine except
        >>for the cboBody combo.  I have looked this over and cannot find any
        >>differences in the combobox's that are working ans the one that is
        >>not         I get the following error message?
        >>Error: "You tried to assign the Null value to a variable that is not a
        >>Variant data type"
        >>
        >>Is the combobox a variable?  Any ideas?- Hide quoted text -
        >>
        >- Show quoted text -

        Comment

        • Greg (codepug@gmail.com)

          #5
          Re: ComboBox (Null value variable error)

          Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
          'Delete combobox entry if Del or Backspace key is hit.
          If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = "" '<--- I
          changed this to 0, and it worked
          End Sub

          I assigned the Me.cboBody = 0 instead of = "" and it worked.
          What's confusing is why the other comboboxes accepted "" and they are
          also storing numbers.




          On Jul 25, 3:32 pm, "Greg (code...@gmail. com)" <code...@gmail. com>
          wrote:
          Thanks JvC
          >
          But my other combo boxes are working.  And, yes you are correct they
          are bound to a Tables field, but I do not
          see, in table design, where I would allow a field to accept null
          values? The field by the way is LongInteger as is the case
          in the other comboboxes that are working.
          >
          Thanks Greg
          >
          On Jul 25, 3:12 pm, JvC <johnv...@earth link.netwrote:
          >
          >
          >
          Your combo box is bound to a field in the database. The field won't
          accept null values. You need to go into the table design, and allow the
          field to allow nulls.
          >
          John
          >
          reg (code...@gmail. com) formulated the question :
          >
          Private Sub cboBody_KeyDown (KeyCode As Integer, SHIFT As Integer)
             'Delete combobox entry if Del or Backspace key is hit.
              If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
          End Sub
          >
          I have used identical code in the KeyDown event of my other comboboxes
          to clear the box when
          the delete or backspace key is pressed.  It works for many identical
          comboboxes just fine except
          for the cboBody combo.  I have looked this over and cannot find any
          differences in the combobox's that are working ans the one that is
          not         I get the following error message?
          >
          Error: "You tried to assign the Null value to a variable that is not a
          Variant data type"
          >
          Is the combobox a variable?  Any ideas?- Hide quoted text -
          >
          - Show quoted text -- Hide quoted text -
          >
          - Show quoted text -

          Comment

          Working...