Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: RE: Building a Recordset


Message #1 by "Joe Conaty" <joec@s...> on Wed, 12 Jun 2002 07:18:03 -0700
I think you are asking something like this - but pls clarify if not...

1- create 2nd rs2 as blank rs with a select statement that returns no 
records ( or just manually create it without any db connection and then 
use rs2.Append to add each field you want displayed in the grid)
2- now loop thru 1st rs and for each record lookup the info you want in 
the grid
3- rs2.AddNew
4 - set the values for the rs2 fields individually
then
5 - set the grid's source to rs2
6
IE: (watch for typos)

        rsUsers.MoveFirst
        While Not rsUsers.EOF
	         rsWatchMe.Source =3D  "SELECT FullName, WatchMe FROM Users 
WHERE " & _
	                   "Name =3D '" & rsUsers("Name") & "'"
=09
            rsWatchMe.Open     'assuming all connection stuff is set 
above

                If rsWatchMe.RecordCount > 0 Then
                    rs2AddNew
                    rs2!FullName =3D rsWatchMe!FullName
                    rs2!WatchMe =3D rsWatchMe!WatchMe
                End If
                rsWatchMe.Close


           rsUsers.MoveNext
       Wend


You can
> -----Original Message-----
> From:	Joe Conaty [SMTP:joec@s...]
> Sent:	Monday, June 10, 2002 3:54 PM
> To:	professional vb
> Subject:	[pro_vb] Building a Recordset
>
> Hello Everyone,
> 
> I'm trying to build a recordset to place in a grid.
> 
> I cant build it the conventional way for reasons to detailed to 
explain.
> 
> Basically I need to grab records from a table based on a recordset 
I've already built.  I'm using a loop, but I'm not returning anything.
> 
> Here is the code.  any thoughts?...
> 
> Dim iCounter As Integer
>         iCounter =3D 0
>         rsUsers.MoveFirst
>        
>     rsWatchMe.CursorType =3D adOpenStatic
>     rsWatchMe.CursorLocation =3D adUseClient
>     rsWatchMe.LockType =3D adLockPessimistic
>                 
>          Do Until rsUsers.EOF
>            
>             rsWatchMe.Source =3D "SELECT FullName, WatchMe FROM Users 
WHERE " & _
>                    "Name =3D '" & rsUsers("Name") & "'"
>               
>                       iCounter =3D iCounter + 1
>                       rsUsers.MoveNext
>                                
>             Loop
> 
>
> Joe Conaty
> Nations Direct IS Dept
>  (xxx) xxx-xxxx  Ext 221
>
> 	
>
> --- Change your mail options at http://p2p.wrox.com/manager.asp or to 
unsubscribe send a blank email to 

  Return to Index