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!

Retrieving checkbox values from access db

Status
Not open for further replies.

markdt

Technical User
Feb 15, 2006
63
GB
Hi,

I have a form which retrieves data from an access db. It works fine with text box, list boxes. But now i have checkboxes, which dont seem to want to show any value.

In the database i have the format of these checkboxes set to true/false. And the value field for the checkboxes i have

<%= rstDBEdit.Fields("HCollect").Value %>

I hope someone can help me!!

Thanks
 
You must provide this code for Checked property of the Checkbox not to the value as:
CheckBox ID="CheckBox1" checked=<%= rstDBEdit.Fields("HCollect").Value %>
Hope this will work!

Sharing the best from my side...

--Prashant--
 
Thanks for the reply,

ive tried that code but it checks it all the time. even if the value from the db isnt checked.

what ive got is:

<input name="chkHCol" type="checkbox" id="chkHCol" checked="<%= rstDBEdit.Fields("HCollect").Value %>" />

any more ideas

cheers
 
Are you saying, it sets 'true' even if the value coming from database is 'false'?
Are you sure that this is not modified by any script thereafter?
Just put response.write for this value just above the checkbox, and check what DB is returning 'True/False'.

Sharing the best from my side...

--Prashant--
 
>But now i have checkboxes, which dont seem to want to show any value.
What do you mean "to show any value". Checkbox value is not shown as visible entity on the client. It is the value to be sent back and be consumed by server. Hence, if you mean some kind of label to it. That is other thing.
[tt]
<label for="chkHCol">
<%= rstDBEdit.Fields("HCollect").Value %>
<input name="chkHCol" type="checkbox" id="chkHCol" value="<%= rstDBEdit.Fields("HCollect").Value %>" />
</label>
[/tt]
(or simplified to without the elaboration to label tag).

If you mean use that value to determine whether it is checked or not by default, then that is another thing. It is done like this.
[tt]
<label for="chkHCol">
somelabeltobeassigned
<%if cbool(rstDBEdit.Fields("HCollect").Value) then%>
<input name="chkHCol" type="checkbox" id="chkHCol" value="somevaluetobeassigned" checked="checked" />
<%else%>
<input name="chkHCol" type="checkbox" id="chkHCol" value="somevaluetobeassigned" />
<%end if%>
</label>
[/tt]
(again can be simplied to without the elaboration to label tag).
 
Yeah tried that and returns the correct values either true or false for the appropriate boxes, but next to the true false the checkboxes are checked, always checked despite being false values!!

have no idea
 
You shouldn't do that:
[tt] checked="whatever_true_or_false"[/tt]
meant simply checked.
 
Sorted thanks for your help.

Used the way tsuji suggested, without the label tag. works just great.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top