Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxes stretch Excel Worksheet Functions 4 September 14th 07 12:36 PM
checkboxes helpless101 Excel Worksheet Functions 0 April 10th 06 11:54 AM
Checkboxes Randy L Excel Discussion (Misc queries) 3 February 22nd 06 08:09 PM
checkboxes marksuza[_3_] Excel Programming 3 December 11th 03 03:19 PM
Checkboxes Thornsberry Excel Programming 1 November 11th 03 03:01 AM


All times are GMT +1. The time now is 08:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"