Do While not Statement

From: Ben (Ben.DunlapHAHA_at_langley.af.mil)
Date: 05/05/04


Date: Wed, 05 May 2004 09:37:26 -0700

I have two 'Do While Not' statements, that are getting information from
the same recordset. If I comment out the first one I can get the results
for the second one, and vice-versa. Why is this happening? Is it because
it's already at the EOF? If so how do I get it back to the BOF for the
2nd 'Do While Not' statement?

'----------------------------------------
'Create an ADO recordset object
Set rs_Report = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT gender, referral, youthmember, age FROM tblUsers WHERE
base = '" + Replace(chosenBase, "'", "''") + "'"

'Open the recordset with the SQL query
rs_Report.Open strSQL, adoCon
        
'-----Gets the total number of male and female users
 intMale = 0
 intFemale = 0
 Do While NOT rs_Report.EOF
   If rs_Report("gender") = "male" then
      intMale = intMale + 1
   Else
      intFemale = intFemale + 1
   End If
 rs_Report.MoveNext()
 Loop
'-----Figures out how they heard about the program

 Do While NOT rs_Report.EOF
   If rs_Report("referral") = "Base Paper" then
      intBasePaper = intBasePaper + 1
   End IF
 rs_Report.MoveNext()
 Loop
----------------------------------------------
--Sample Output--
 Male = 11
 Female = 4

 Base Paper =__ "nothing is returned here"

----------------------------------------------
Like I said before If I comment out the first do while not statement I
can get the answers for the second one. If I don't it doesn't even get
inside of the second do while not statement.

I know I can fix it by just having a seperate SQL statement to the
database and get my information seperately, but it seems like a waste of
time. Thanks for any help.

-=Ben
-=To email me take out the joke.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Response.write statement does not work properly
    ... the result of the sql statement in the page before opening ... the recordset. ... False as Response.write value of the sql statement. ... strsql = "SELECT tblGMISSpecialConditions.IntID, ...
    (microsoft.public.inetserver.asp.db)
  • Re: Do While not Statement
    ... Loop ... > the same recordset. ... > 'Initialise the strSQL variable with an SQL statement to query the ...
    (microsoft.public.inetserver.asp.general)
  • Re: Do While not Statement
    ... your code work add rs_Report.Movefirst prior to starting the second loop. ... > the same recordset. ... > 'Initialise the strSQL variable with an SQL statement to query the ... > I know I can fix it by just having a seperate SQL statement to the ...
    (microsoft.public.inetserver.asp.general)
  • Source size and how to change
    ... Here is recordset that I am trying to open. ... problem is the variable (strSQL) holding the sql statement is truncating the ... It must be happening in the ADO call because the actual variable ...
    (microsoft.public.data.ado)
  • Re: Using For...Each loops when referencing reports.
    ... SELECT tblTx.*, tblTestTx.* FROM tblTx INNER JOIN tblTestTx ON ... 199 is just the ID in your last SQL statement. ... This will now write the exact SQL statement used to open the recordset to ...
    (microsoft.public.access.modulesdaovba)