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!

Updating Yes/No field in Access 2000

Status
Not open for further replies.

ajra

Programmer
Aug 14, 2002
3
US
I have a table called Nominations. One of the fields is called Validated. On the asp page, I loop through the records and display all records where Validated = false. I have a checkbox(chkValidate) next to the person's name and have set the value of that checkbox to <%=NominationRS.Fields(&quot;ID&quot;)%>, the nomination id.

What should happen:
The user clicks the text boxes for the nominations they want to validate. The IDs of the ones they clicked are collected in chkValidate, which is then split into an array. Then, in a loop, I want to find the records in the table that match each ID number and set Valdated = true.

Problem:
I have tried
ValidateRS.Fields(&quot;Validated&quot;) = true
ValidateRS.Fields(&quot;Validated&quot;) = -1
ValidateRS.Fields(&quot;Validated&quot;) = yes
ValidateRS(&quot;Validated&quot;) = true
ValidateRS(&quot;Validated&quot;) = -1
ValidateRS(&quot;Validated&quot;) = yes

none of which has consistently set Validated to true. The first one seemed to be working, then mysteriously has not worked again.
How can I set this field in the database? I know there is a way to do it individually, using separate pages; that solution is not acceptable for my boss.
 
Can you simply write a small SQL script that will update the records, for example....

while i=1 to numrecs
Dim SQL1, rst1
set rst1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
SQL1 = &quot; UPDATE Nominations set Validation = 1 where ID=&quot;&i
rst1.Open SQL1, conn
loop

HTH


_______________________________________________
OutsideIntranets.com
Stop wasting time, get to work
 
OK - Now I have tried:

vNominees = request.form(&quot;chkValidate&quot;)

'now set an array to the nominees
arrNom = split(vNominees, &quot;,&quot;)

'now loop through the array and update the DB
for i=0 to ubound(arrNom)
strQuery = &quot;UPDATE Nominations SET (Validated=&quot; & CBool(true) & &quot;) WHERE Nomination_ID=&quot; & arrNom(i)

cmdDC.CommandText = strQuery
cmdDC.Execute

next

And it still is not updating the database.
 
I think the query is incorrect.
strQuery should be ...

strQuery=&quot;UPDATE Nominations SET Validated=&quot; & CBool(true) & &quot; WHERE Nomination_ID=&quot; & arrNom(i)

without the parentheses.

Also, you can comment out the execute line, and add in a
response.write strQuery
to make sure your sql queries are syntactically correct.

_______________________________________________
OutsideIntranets.com
Stop wasting time, get to work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top