I've created an Access table with, among other fields, a set of numbered text fields. Follow1, Follow2, Follow3, etc., all the way to Follow10. They're non-required, and have no default value.
Now what I need to do is loop through each field and display the contents of each field, but first I need to check to make sure it's not empty. When the loop finds the first empty field, it ends and no more code is executed.
I'm having difficulty with the looping logic, though. As it stands now, the script will only execute the if-then code representing a non-empty field, meaning it's not recognizing the empty fields as actually being empty. The script is attempting to display 5 fields each time, regardless of whether there is content or not. If all the text fields are blank, it will display 5 line breaks. I don't know why this is happening.
The way I've set it up is through an array declaration at the beginning, with each element matched up with the corresponding text field. I then use a for-next loop to run through the array and check each element to make sure it's not empty.
Here's the Array declaration:
<%
Query = "SELECT * FROM itemlog WHERE num = " & Request("num")
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "p2k2"
Set RSlist = Server.CreateObject("ADODB.recordset")
RSlist.Open Query,DataConn,1,2
exist = "true"
Dim thenotes(10)
thenotes(0) = RSlist("follow1")
thenotes(1) = RSlist("follow2")
thenotes(2) = RSlist("follow3")
thenotes(3) = RSlist("follow4")
thenotes(4) = RSlist("follow5")
thenotes(5) = RSlist("follow6")
thenotes(6) = RSlist("follow7")
thenotes(7) = RSlist("follow8")
thenotes(8) = RSlist("follow9")
thenotes(9) = RSlist("follow10")
%>
And here's the loop:
<%Do Until exist = "false" Or RSlist.EOF
For i = 0 to 9
if thenotes(i) = "" then
exist = "false"
else
Response.Write thenotes(i)
Response.Write "<BR><BR>"
i = i+1
End If
Next
RSlist.Movenext
Loop%>
Any ideas? Any/all help is appreciated.