Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ADO and Checkboxes
I am connecting to an Access Database with ADO
I have a small issue when trying to set the value of a checkbox on a form ADO returns True and False from the database The checkbox wants vbChecked and vbUnchecked The True keyword has a value equal to -1. The False keyword has a value equal to 0. The vbChecked keyword has a value equal to 1. The vbUnchecked keyword has a value equal to 0. I created my own function that is listed bellow but I was wondering 1) Is there a built in function that converts these? 2) Is there a setting either in the database or on my checkbox that I can make the checkbox and ADO field compatible? 3) Looking at it I could just multiply it by -1 and it would come out too. Is this a valid solution? Private Function CheckBoxValueFromBoolean(ValueToConvert As Boolean) As Integer 'Translate ValueToConvert If ValueToConvert = True Then CheckBoxValueFromBoolean = vbChecked Else CheckBoxValueFromBoolean = vbUnchecked End If End Function Thanks in Advance -Merk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ADO and Checkboxes
Use the IIf() function in the SQL statement to check for a zero value e.g.
SELECT KeyCol, IIF(ValueCol=0,0,-1) AS ValueCol FROM MyTable -- "Merkling, wrote in message ... I am connecting to an Access Database with ADO I have a small issue when trying to set the value of a checkbox on a form ADO returns True and False from the database The checkbox wants vbChecked and vbUnchecked The True keyword has a value equal to -1. The False keyword has a value equal to 0. The vbChecked keyword has a value equal to 1. The vbUnchecked keyword has a value equal to 0. I created my own function that is listed bellow but I was wondering 1) Is there a built in function that converts these? 2) Is there a setting either in the database or on my checkbox that I can make the checkbox and ADO field compatible? 3) Looking at it I could just multiply it by -1 and it would come out too. Is this a valid solution? Private Function CheckBoxValueFromBoolean(ValueToConvert As Boolean) As Integer 'Translate ValueToConvert If ValueToConvert = True Then CheckBoxValueFromBoolean = vbChecked Else CheckBoxValueFromBoolean = vbUnchecked End If End Function Thanks in Advance -Merk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checkboxes | Excel Worksheet Functions | |||
checkboxes | Excel Worksheet Functions | |||
Checkboxes | Excel Discussion (Misc queries) | |||
checkboxes | Excel Programming | |||
Checkboxes | Excel Programming |