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

loop through recordset

Status
Not open for further replies.

peteswrx

Programmer
Sep 16, 2002
12
US
I have a DOB text box ("txtDOB") on my form. I want to be able to loop through a recordset so that where "txtDOB" = rsinfo("DOB_FIELD"), the user will see a messagebox and then response.end.

Here's my code sofar:

if (request.form("chkTwin") = "") then
rsbabyinfo.MoveFirst
do while not rsbabyinfo.EOF
if request.form("txtDOB")=rsbabyinfo("BABY_DOB") then
%>
<script language=&quot;vbscript&quot;>
msgbox &quot;You must check 'TWIN' if you want to enter a baby with the same DOB as another&quot;
</script>
<%
response.end
end if
rsbabyinfo.movenext
Loop
end if
 
Are you making you're connection to the DB rate before this code ?? use the <VBscript> tag jsut inclose the statement into the %> like this
if (request.form(&quot;chkTwin&quot;) = &quot;&quot;) then
rsbabyinfo.MoveFirst
do while not rsbabyinfo.EOF
if request.form(&quot;txtDOB&quot;)=rsbabyinfo(&quot;BABY_DOB&quot;) then
Dim MyVar
MyVar = MsgBox (&quot;You must check 'TWIN' if you want to enter a baby with the same DOB as another&quot;)
end if
response.end
rsbabyinfo.movenext
Loop
end if
You do not need to provide tools to let people become their best.
 
I couldn't get this to work. I think it hits response.end, but the messagebox never pops up.

and yes, i'm connecting to the DB before this code.
 
The 'TWIN' quotes may be causing problems. I'll reaply if you do not have it going when I get home. Hope I helped so far provide tools to let people become their best.
 
Thank you very much for all of your help.

i'll try removing the quotes once i'm back at work monday.

thanks!!
 
Thank you very much for all of your help.

i'll try removing the quotes once i'm back at work monday.

thanks!!
 
Thank you very much for all of your help.

i'll try removing the quotes once i'm back at work monday.

thanks!!
 
see if this works out
DIM chk, DOB, MyVar
chk = request.form(&quot;chkTwin&quot;)
DOB = request.form(&quot;txtDOB&quot;)
if (chk = &quot;&quot;) then
rsbabyinfo.MoveFirst
do while not rsbabyinfo.EOF
if DOB = rsbabyinfo(&quot;BABY_DOB&quot;) then
MyVar = MsgBox (&quot;You must check TWIN if you want to enter a baby with the same DOB as another&quot;)
Response.End
end if
rsbabyinfo.movenext
Loop
end if


if this doesn't work out let me know what error you are getting
provide tools to let people become their best.
 
For some reason it's not hitting this code. i'll look into it a little further, however your syntax/method looks correct. I think there's a different problem here though.

Thanks for all your help!

Pete
 
Nope. The loop through recordset code (movefirst/movenext) is not working. I checked to see if I have an active record before and after the code and I do... What could be the problem??
 
Here's my modified version: If I was to uncomment the response.write, I would see every DOB for that record, so that is working, but the line &quot;if (DOB = rsbabyinfo.....) is not working>>>

if (chk= &quot;&quot;) then
rsbabyinfo.MoveFirst
do until rsbabyinfo.EOF
if (DOB = rsbabyinfo(1).value) then
response.write &quot;You must check TWIN if you want to enter a baby with the same DOB as another&quot;
Response.End
end if
''response.write rsbabyinfo(1).value
rsbabyinfo.movenext
Loop

end if
 
try this instead
if (DOB = rsbabyinfo.Fields(1).value) then I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top