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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Check Box Vaulues from Access

Status
Not open for further replies.

jvet4

Technical User
Jul 24, 2000
54
US
Hello...
I am pretty new to ASP so please bear with me. I have a form in which the user enters information using multiple checkboxes all of which have the same (and different values). These values are sent to a database where they are parsed and put into a table and assigned an ID (there are 9 checkboxes, so there can be up to 9 records per ID).
I am now trying to set up a new form that allows the user to modify their selections. I want to be able to display a form that shows which checkboxes have been selected and leave the others blank.
How do I write code that looks at the database and determines if the checkbox is selected or not.

Thanks, Jason
 
U have to use sothing like this ASP file example

<%
Set Connection = Server.CreateObject(&quot;adodb.connection&quot;)
DSN = &quot;Provider=Microsoft.Jet.OLEDB.3.51;Data Source=&quot;&Server.MapPath(&quot;YourAccesDatabase.mdb&quot;)
Connection.Open DSN

Const adOpenStatic = 3
Const adUseClient = 3
Const adLockPessimistic = 2

set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)

sub ExecuteSQL(byval cmd)
if rs.State=1 then rs.Close
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Source = cmd
rs.ActiveConnection = Connection 'The record set needs to know what connection to use.
rs.Open
end sub
%>
...
<%
SQL=&quot;select id1,id2,id3,id4,id5,id6,id7,id8,id9 from MyDataBaseName&quot;
ExecuteSQL(SQL)
if rs.RecordCount=0 then
'we do not have recordsets in database
end if
%>
...
<INPUT type=&quot;checkbox&quot; id=id1 name=id1
<%if rs(&quot;id1&quot;)=&quot;checked&quot; then%>
checked>
<%else%>
>
<%end if%>
...
and so for each id


if id1 is checked then the html it look like
<INPUT type=&quot;checkbox&quot; id=id1 name=id1 checked>
if not
<INPUT type=&quot;checkbox&quot; id=id1 name=id1>

if u have another way to acess your database use it but u have to use or rename the Recorset Object rs
hope this helps u...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top