Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding a Checkbox to a recordset

Status
Not open for further replies.

sergiog

Programmer
Feb 17, 2003
24
0
0
MT
Hi

i have a recordset returning a recordset, in which i have 4 boolean fields.

i also have a bindingcollection in which i am adding 4 checkboxes like so

colbind.add chkView,"Value","View"

no, this line gives me error "invalid property value"

All i want is the checkbox to be unchecked when the value in the recordset is false and to be checked when the value is false.

any better ideas please ?
thanks
 
The way I have done this is, create a text box(hidden) that represents the check box. so when you check the checkbox the textbox gets stamped with whatever you want..

so, if you have a checkbox called chkYes, create txtYes.

If chkYes.Value = 1 Then
txtYes.Text = "YES"
End If

If chkYes.Value = 0 Then
txtYes.Text = ""
End If

Then when you load the form simply say

If txtYes.Text = "YES" Then
chkYes.Value = 1
Else
chkYes.Value = 0
End If

of course you would have to write txtYes back to your DB.

 
You could do it much more simple.

You should fill in the 'datasource' and 'datafield' properties in the propertieswindow.

I have don it in a project and it works there.
 
thanks guys.

i used a datacombo and i set its rowsource, rowmember, listfield and boundcolumn properties and it worked perfect.

cheers
sergio.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top