CheckBoxes


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: CheckBoxes

Hybrid View

  1. #1
    Chris Guest

    CheckBoxes


    In a database project I'm using class modules to read and write from the data
    base to controls and from controls to the database.I'm using Access 2000
    as the back end database and ADO for data base access. The problem is with
    the check box controls. Access stores Boolean values as '0 = False' and '-1
    = True' yet the checkbox values are '0 (unchecked)= False' and '1 (checked)=
    True' therefore the following code draws the

    Runtime Error '380' Invalid property value:

    Public Sub OtoF()
    chkCheckBox = m_checkBox 'm_checkBox value is true
    End Sub

    Public Sub FtoO()
    m_checkBox = chkCheckBox 'chkCheckBox is checked
    End Sub

    Does anyone know how to get around this?

    Chris



  2. #2
    Paul Clement Guest

    Re: CheckBoxes

    On 18 Jul 2000 11:39:22 -0700, "Chris" <chrisc@ausam.com> wrote:


    In a database project I'm using class modules to read and write from the data
    base to controls and from controls to the database.I'm using Access 2000
    as the back end database and ADO for data base access. The problem is with
    the check box controls. Access stores Boolean values as '0 = False' and '-1
    = True' yet the checkbox values are '0 (unchecked)= False' and '1 (checked)=
    True' therefore the following code draws the

    Runtime Error '380' Invalid property value:

    Public Sub OtoF()
    chkCheckBox = m_checkBox 'm_checkBox value is true
    End Sub

    Public Sub FtoO()
    m_checkBox = chkCheckBox 'chkCheckBox is checked
    End Sub

    Does anyone know how to get around this?

    Only way to do it is check if the field value is True, and if so set the value to vbChecked. Or,
    change the field type at the database table level to integer instead of boolean in order to store
    the value of vbChecked (1) or vbUnchecked (0).


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    Jim Edgar Guest

    Re: CheckBoxes

    Chris --

    > Public Sub OtoF()
    > chkCheckBox = m_checkBox 'm_checkBox value is true
    > End Sub
    >
    > Public Sub FtoO()
    > m_checkBox = chkCheckBox 'chkCheckBox is checked
    > End Sub
    >


    The CInt() function returns -1 for True and 0 for False. Try this:

    Public Sub OtoF()
    chkCheckBox = CInt(m_checkBox) 'm_checkBox value is true
    End Sub

    Public Sub FtoO()
    m_checkBox = chkCheckBox 'chkCheckBox is checked
    End Sub

    Another option is to declare m_checkBox as an Integer.

    Hope it helps,
    Jim Edgar



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center