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

Response.Write based on content of recordset field

Status
Not open for further replies.

cactus1000

Programmer
Aug 31, 2001
149
US
I asked a similar question a few days ago, but I'm still stuck.

Each record on my database has a name field which must be filled out, however, users can check "anonymous" on the web form if they wish for their names to be hidden.

So, when output is displayed, the names should be displayed for everyone except those who checked "anonymous"

So I have an If statement:


If (objrs.Fields.Item("anonymous")) = "Yes" Then


Do While Not objrs.EOF

Response.Write (field1)
Response.Write (field2)

objRS.MoveNext
Loop

End If

If (objrs.Fields.Item("anonymous")) = "No" Then

Do While Not objrs.EOF

Response.Write (Name)
Response.Write (field1)
Response.Write (field2)

objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing

End If

What this is doing is checking the recordset -- if the first record's "anonymous" field is "yes" it applies the "Yes" criteria to all records. If the first record is a "No", it applies the "No" criteria to all records.

How can I get this If statement to execute for each individual record?

Or, rather than having alternate Response.Write options, is there a way to hide the name field based on the contents of the "anonymous" field?




 
Do this:

Do While Not objrs.EOF

If (objrs.Fields.Item("anonymous")) = "Yes" Then
Response.Write (field1)
Response.Write (field2)
elseIf (objrs.Fields.Item("anonymous")) = "No" Then
Response.Write (Name)
Response.Write (field1)
Response.Write (field2)
end if

objRS.MoveNext
Loop

End If
objRS.Close
Set objRS = Nothing
"did you just say Minkey?, yes that's what I said."

MrGreed
 
Actually could do this:

Do While Not objrs.EOF

If (objrs.Fields.Item("anonymous")) = "No" Then
Response.Write (Name)
end if

Response.Write (field1)
Response.Write (field2)

objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing "did you just say Minkey?, yes that's what I said."

MrGreed
 
Thank You!

Excuse me while I bang my head against my desk for a while...
 
Your Welcome "did you just say Minkey?, yes that's what I said."

MrGreed
 
By the way, I used option #2

You've saved me a lot of work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top