 |
|
 |
|
Next: Memo fields & Hyperlinks
|
| Author |
Message |
External

Since: Apr 02, 2004 Posts: 6
|
(Msg. 1) Posted: Mon Feb 21, 2005 1:40 pm
Post subject: ADO recordset question Archived from groups: microsoft>public>vb>database>ado (more info?)
|
|
|
Hello all.
This is such a basic question, but I can't find an answer.
I have a function in a class module that finds data from a series of
database tables. The data, when found, is placed into a new recordset within
the function. All OK here.
Now, where I am stuck is how do I make a query from this query?
For example, I have my new recordset in my function that contain all of the
data that I have extracted from the database tables, now I want to search
that recordset for a further sub set of data, that is where I am stuck. OK,
I could bung it all into a temporary table, but that will hit the
performance of my app. So I thought of querying the query instead
A snippet of code to illustrate follows:
'In a class module
Public Function Some_Function(strTable As String, strMedianTbl As String,
strField As String, strPast As String, sSurvey As Integer, ByVal LabID As
Long) As String
Dim NewRS As New ADODB.Recordset
Dim RsResult As New ADODB.Recordset
Dim ReagentID As Integer 'The ReagentID for that survey
Dim WHOSurvey As Integer 'The WHOSurvey for that survey
ReagentID = 0
WHOSurvey = 0
With cnNEQAS
.Open
.CursorLocation = adUseClient
With NewRS.Fields 'First define the fields of the new recordset
.Append "LabID", adInteger, 4
.Append "Survey", adInteger, 4
.Append "Used", adVarChar, 7
.Append "Dev", adSingle, 7
End With
With NewRS
.Open
End With
strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." & strPast
& ", SomeTable.ReagentID " _
& "FROM SomeTable INNER JOIN WHOSampleNo ON SomeTable.Survey =
SampleNo.SurveyN " _
& "Where (((SomeTable.LabID) = " & LabID & ") AND
((SomeTable.Survey)<= " & sSurvey & ")) " _
& "ORDER BY SomeTable.Survey"
rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
Set rsGeneric.ActiveConnection = Nothing
strSQL = ""
If rsGeneric.RecordCount > 0 Then
With rsGeneric
.MoveFirst
Do While Not .EOF
ReagentID = !ReagentID
WHOSurvey = !Survey
'here I save the data that matches my criteria
If RsResult.RecordCount > 0 Then
With NewRS
'Push into a new recordset
.AddNew
!LabID = RsResult!LabID
!Survey = RsResult!Survey
!Dev = (Format(RsResult![Dev], "###0.00"))
.Update
.MoveNext
End With
Set RsResult = Nothing
>>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
ELSE
.....Some other action
......
....
End If
Loop
etc
<<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
'Query the recordset (NewRs) obtained from above and do something with it.
strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio " _
& "FROM NewRs " _
& "ORDER BY NewRs.Survey ASC"
RsResult.Open strSQL, cnNEQAS, , , adCmdText
Set RsResult.ActiveConnection = Nothing
strSQL = ""
Obviously, here I get an error that states that there is no table or query
called NewRS in the database
..........................
How do I query this NewRs please?
Thank you for any help that you can give me.
Best regards
David clifford >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2004 Posts: 123
|
(Msg. 2) Posted: Mon Feb 21, 2005 1:40 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
The best you would be able to do is use the Find or Filter methods of the
recordset - note both are limiting..
Find:
<a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_find.html" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</a>
Filter:
<a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</a>
--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
<a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp" target="_blank">http://www.veign.com/vrc_main.asp</a>
--
"David Clifford" wrote in message
> Hello all.
>
> This is such a basic question, but I can't find an answer.
>
> I have a function in a class module that finds data from a series of
> database tables. The data, when found, is placed into a new recordset
within
> the function. All OK here.
> Now, where I am stuck is how do I make a query from this query?
>
> For example, I have my new recordset in my function that contain all of
the
> data that I have extracted from the database tables, now I want to search
> that recordset for a further sub set of data, that is where I am stuck.
OK,
> I could bung it all into a temporary table, but that will hit the
> performance of my app. So I thought of querying the query instead
>
> A snippet of code to illustrate follows:
>
> 'In a class module
>
> Public Function Some_Function(strTable As String, strMedianTbl As String,
> strField As String, strPast As String, sSurvey As Integer, ByVal LabID As
> Long) As String
>
>
> Dim NewRS As New ADODB.Recordset
> Dim RsResult As New ADODB.Recordset
>
> Dim ReagentID As Integer 'The ReagentID for that survey
> Dim WHOSurvey As Integer 'The WHOSurvey for that survey
>
> ReagentID = 0
> WHOSurvey = 0
>
> With cnNEQAS
> .Open
> .CursorLocation = adUseClient
>
> With NewRS.Fields 'First define the fields of the new recordset
> .Append "LabID", adInteger, 4
> .Append "Survey", adInteger, 4
> .Append "Used", adVarChar, 7
> .Append "Dev", adSingle, 7
> End With
>
> With NewRS
> .Open
> End With
>
>
> strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
strPast
> & ", SomeTable.ReagentID " _
> & "FROM SomeTable INNER JOIN WHOSampleNo ON SomeTable.Survey =
> SampleNo.SurveyN " _
> & "Where (((SomeTable.LabID) = " & LabID & ") AND
> ((SomeTable.Survey)<= " & sSurvey & ")) " _
> & "ORDER BY SomeTable.Survey"
>
> rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> Set rsGeneric.ActiveConnection = Nothing
> strSQL = ""
>
> If rsGeneric.RecordCount > 0 Then
> With rsGeneric
> .MoveFirst
> Do While Not .EOF
>
> ReagentID = !ReagentID
> WHOSurvey = !Survey
>
> 'here I save the data that matches my criteria
>
> If RsResult.RecordCount > 0 Then
> With NewRS
> 'Push into a new recordset
> .AddNew
> !LabID = RsResult!LabID
> !Survey = RsResult!Survey
> !Dev = (Format(RsResult![Dev], "###0.00"))
> .Update
> .MoveNext
> End With
> Set RsResult = Nothing
> >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
>
>
> ELSE
>
> ....Some other action
> .....
> ...
> End If
> Loop
> etc
>
> <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
>
> 'Query the recordset (NewRs) obtained from above and do something with it.
>
> strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio " _
> & "FROM NewRs " _
> & "ORDER BY NewRs.Survey ASC"
> RsResult.Open strSQL, cnNEQAS, , , adCmdText
> Set RsResult.ActiveConnection = Nothing
> strSQL = ""
>
> Obviously, here I get an error that states that there is no table or query
> called NewRS in the database
> .........................
>
> How do I query this NewRs please?
>
>
> Thank you for any help that you can give me.
>
> Best regards
>
> David clifford
>
>
>
> >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Apr 02, 2004 Posts: 6
|
(Msg. 3) Posted: Mon Feb 21, 2005 3:40 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hummm..thanks for that information Chris...I'm not too sure that it would
accomplish what I am looking for though. Are you saying that it would
probably be better to write the whole lot to a temp table in the first
place?
Best regards.
David Clifford
"Veign" wrote in message
> The best you would be able to do is use the Find or Filter methods of the
> recordset - note both are limiting..
>
> Find:
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font</a>>
>
> Filter:
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font</a>>
>
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
> --
>
> > Hello all.
> >
> > This is such a basic question, but I can't find an answer.
> >
> > I have a function in a class module that finds data from a series of
> > database tables. The data, when found, is placed into a new recordset
> within
> > the function. All OK here.
> > Now, where I am stuck is how do I make a query from this query?
> >
> > For example, I have my new recordset in my function that contain all of
> the
> > data that I have extracted from the database tables, now I want to
search
> > that recordset for a further sub set of data, that is where I am stuck.
> OK,
> > I could bung it all into a temporary table, but that will hit the
> > performance of my app. So I thought of querying the query instead
> >
> > A snippet of code to illustrate follows:
> >
> > 'In a class module
> >
> > Public Function Some_Function(strTable As String, strMedianTbl As
String,
> > strField As String, strPast As String, sSurvey As Integer, ByVal LabID
As
> > Long) As String
> >
> >
> > Dim NewRS As New ADODB.Recordset
> > Dim RsResult As New ADODB.Recordset
> >
> > Dim ReagentID As Integer 'The ReagentID for that survey
> > Dim WHOSurvey As Integer 'The WHOSurvey for that survey
> >
> > ReagentID = 0
> > WHOSurvey = 0
> >
> > With cnNEQAS
> > .Open
> > .CursorLocation = adUseClient
> >
> > With NewRS.Fields 'First define the fields of the new recordset
> > .Append "LabID", adInteger, 4
> > .Append "Survey", adInteger, 4
> > .Append "Used", adVarChar, 7
> > .Append "Dev", adSingle, 7
> > End With
> >
> > With NewRS
> > .Open
> > End With
> >
> >
> > strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
> strPast
> > & ", SomeTable.ReagentID " _
> > & "FROM SomeTable INNER JOIN WHOSampleNo ON SomeTable.Survey =
> > SampleNo.SurveyN " _
> > & "Where (((SomeTable.LabID) = " & LabID & ") AND
> > ((SomeTable.Survey)<= " & sSurvey & ")) " _
> > & "ORDER BY SomeTable.Survey"
> >
> > rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> > Set rsGeneric.ActiveConnection = Nothing
> > strSQL = ""
> >
> > If rsGeneric.RecordCount > 0 Then
> > With rsGeneric
> > .MoveFirst
> > Do While Not .EOF
> >
> > ReagentID = !ReagentID
> > WHOSurvey = !Survey
> >
> > 'here I save the data that matches my criteria
> >
> > If RsResult.RecordCount > 0 Then
> > With NewRS
> > 'Push into a new recordset
> > .AddNew
> > !LabID = RsResult!LabID
> > !Survey = RsResult!Survey
> > !Dev = (Format(RsResult![Dev], "###0.00"))
> > .Update
> > .MoveNext
> > End With
> > Set RsResult = Nothing
> > >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
> >
> >
> > ELSE
> >
> > ....Some other action
> > .....
> > ...
> > End If
> > Loop
> > etc
> >
> > <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
> >
> > 'Query the recordset (NewRs) obtained from above and do something with
it.
> >
> > strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio " _
> > & "FROM NewRs " _
> > & "ORDER BY NewRs.Survey ASC"
> > RsResult.Open strSQL, cnNEQAS, , , adCmdText
> > Set RsResult.ActiveConnection = Nothing
> > strSQL = ""
> >
> > Obviously, here I get an error that states that there is no table or
query
> > called NewRS in the database
> > .........................
> >
> > How do I query this NewRs please?
> >
> >
> > Thank you for any help that you can give me.
> >
> > Best regards
> >
> > David clifford
> >
> >
> >
> >
>
> >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2004 Posts: 123
|
(Msg. 4) Posted: Mon Feb 21, 2005 3:40 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
More flexibility with the ability to use SQL...
Look into the SELECT INTO statement;
I have a SQL Reference guide in my Application Dev Resource Area that show
examples of the SELECT INTO.
--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
<a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp" target="_blank">http://www.veign.com/vrc_main.asp</a>
--
"David Clifford" wrote in message
> Hummm..thanks for that information Chris...I'm not too sure that it would
> accomplish what I am looking for though. Are you saying that it would
> probably be better to write the whole lot to a temp table in the first
> place?
>
> Best regards.
>
> David Clifford
>
> > The best you would be able to do is use the Find or Filter methods of
the
> > recordset - note both are limiting..
> >
> > Find:
<font color=green> > > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font</a>>
> >
> > Filter:
<font color=green> > > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font</a>>
> >
> >
> > --
> > Chris Hanscom - Microsoft MVP (VB)
> > Veign's Resource Center
<font color=green> > > <a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
> > --
> >
> > > Hello all.
> > >
> > > This is such a basic question, but I can't find an answer.
> > >
> > > I have a function in a class module that finds data from a series of
> > > database tables. The data, when found, is placed into a new recordset
> > within
> > > the function. All OK here.
> > > Now, where I am stuck is how do I make a query from this query?
> > >
> > > For example, I have my new recordset in my function that contain all
of
> > the
> > > data that I have extracted from the database tables, now I want to
> search
> > > that recordset for a further sub set of data, that is where I am
stuck.
> > OK,
> > > I could bung it all into a temporary table, but that will hit the
> > > performance of my app. So I thought of querying the query instead
> > >
> > > A snippet of code to illustrate follows:
> > >
> > > 'In a class module
> > >
> > > Public Function Some_Function(strTable As String, strMedianTbl As
> String,
> > > strField As String, strPast As String, sSurvey As Integer, ByVal LabID
> As
> > > Long) As String
> > >
> > >
> > > Dim NewRS As New ADODB.Recordset
> > > Dim RsResult As New ADODB.Recordset
> > >
> > > Dim ReagentID As Integer 'The ReagentID for that survey
> > > Dim WHOSurvey As Integer 'The WHOSurvey for that survey
> > >
> > > ReagentID = 0
> > > WHOSurvey = 0
> > >
> > > With cnNEQAS
> > > .Open
> > > .CursorLocation = adUseClient
> > >
> > > With NewRS.Fields 'First define the fields of the new recordset
> > > .Append "LabID", adInteger, 4
> > > .Append "Survey", adInteger, 4
> > > .Append "Used", adVarChar, 7
> > > .Append "Dev", adSingle, 7
> > > End With
> > >
> > > With NewRS
> > > .Open
> > > End With
> > >
> > >
> > > strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
> > strPast
> > > & ", SomeTable.ReagentID " _
> > > & "FROM SomeTable INNER JOIN WHOSampleNo ON SomeTable.Survey
=
> > > SampleNo.SurveyN " _
> > > & "Where (((SomeTable.LabID) = " & LabID & ") AND
> > > ((SomeTable.Survey)<= " & sSurvey & ")) " _
> > > & "ORDER BY SomeTable.Survey"
> > >
> > > rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> > > Set rsGeneric.ActiveConnection = Nothing
> > > strSQL = ""
> > >
> > > If rsGeneric.RecordCount > 0 Then
> > > With rsGeneric
> > > .MoveFirst
> > > Do While Not .EOF
> > >
> > > ReagentID = !ReagentID
> > > WHOSurvey = !Survey
> > >
> > > 'here I save the data that matches my criteria
> > >
> > > If RsResult.RecordCount > 0 Then
> > > With NewRS
> > > 'Push into a new recordset
> > > .AddNew
> > > !LabID = RsResult!LabID
> > > !Survey = RsResult!Survey
> > > !Dev = (Format(RsResult![Dev], "###0.00"))
> > > .Update
> > > .MoveNext
> > > End With
> > > Set RsResult = Nothing
> > > >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
> > >
> > >
> > > ELSE
> > >
> > > ....Some other action
> > > .....
> > > ...
> > > End If
> > > Loop
> > > etc
> > >
> > > <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
> > >
> > > 'Query the recordset (NewRs) obtained from above and do something with
> it.
> > >
> > > strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio " _
> > > & "FROM NewRs " _
> > > & "ORDER BY NewRs.Survey ASC"
> > > RsResult.Open strSQL, cnNEQAS, , , adCmdText
> > > Set RsResult.ActiveConnection = Nothing
> > > strSQL = ""
> > >
> > > Obviously, here I get an error that states that there is no table or
> query
> > > called NewRS in the database
> > > .........................
> > >
> > > How do I query this NewRs please?
> > >
> > >
> > > Thank you for any help that you can give me.
> > >
> > > Best regards
> > >
> > > David clifford
> > >
> > >
> > >
> > >
> >
> >
>
> >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Apr 02, 2004 Posts: 6
|
(Msg. 5) Posted: Mon Feb 21, 2005 4:40 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
OK, temp table it is. I have used the Select Into statement quite a bit
before. Still, pity it can't be done more eloquently and directly from the
query recordset though. Thank you very much for your input and time.
Best reards.
David Clifford
"Veign" wrote in message
> More flexibility with the ability to use SQL...
>
> Look into the SELECT INTO statement;
>
> I have a SQL Reference guide in my Application Dev Resource Area that show
> examples of the SELECT INTO.
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
<font color=purple> > <a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
> --
>
> > Hummm..thanks for that information Chris...I'm not too sure that it
would
> > accomplish what I am looking for though. Are you saying that it would
> > probably be better to write the whole lot to a temp table in the first
> > place?
> >
> > Best regards.
> >
> > David Clifford
> >
> > > The best you would be able to do is use the Find or Filter methods of
> the
> > > recordset - note both are limiting..
> > >
> > > Find:
<font color=brown> > > > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_find.html</font</a>>
> > >
> > > Filter:
<font color=brown> > > > <a rel="nofollow" style='text-decoration: none;' href="http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font" target="_blank">http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html</font</a>>
> > >
> > >
> > > --
> > > Chris Hanscom - Microsoft MVP (VB)
> > > Veign's Resource Center
<font color=brown> > > > <a rel="nofollow" style='text-decoration: none;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
> > > --
> > >
> > > > Hello all.
> > > >
> > > > This is such a basic question, but I can't find an answer.
> > > >
> > > > I have a function in a class module that finds data from a series of
> > > > database tables. The data, when found, is placed into a new
recordset
> > > within
> > > > the function. All OK here.
> > > > Now, where I am stuck is how do I make a query from this query?
> > > >
> > > > For example, I have my new recordset in my function that contain all
> of
> > > the
> > > > data that I have extracted from the database tables, now I want to
> > search
> > > > that recordset for a further sub set of data, that is where I am
> stuck.
> > > OK,
> > > > I could bung it all into a temporary table, but that will hit the
> > > > performance of my app. So I thought of querying the query instead
> > > >
> > > > A snippet of code to illustrate follows:
> > > >
> > > > 'In a class module
> > > >
> > > > Public Function Some_Function(strTable As String, strMedianTbl As
> > String,
> > > > strField As String, strPast As String, sSurvey As Integer, ByVal
LabID
> > As
> > > > Long) As String
> > > >
> > > >
> > > > Dim NewRS As New ADODB.Recordset
> > > > Dim RsResult As New ADODB.Recordset
> > > >
> > > > Dim ReagentID As Integer 'The ReagentID for that survey
> > > > Dim WHOSurvey As Integer 'The WHOSurvey for that survey
> > > >
> > > > ReagentID = 0
> > > > WHOSurvey = 0
> > > >
> > > > With cnNEQAS
> > > > .Open
> > > > .CursorLocation = adUseClient
> > > >
> > > > With NewRS.Fields 'First define the fields of the new
recordset
> > > > .Append "LabID", adInteger, 4
> > > > .Append "Survey", adInteger, 4
> > > > .Append "Used", adVarChar, 7
> > > > .Append "Dev", adSingle, 7
> > > > End With
> > > >
> > > > With NewRS
> > > > .Open
> > > > End With
> > > >
> > > >
> > > > strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
> > > strPast
> > > > & ", SomeTable.ReagentID " _
> > > > & "FROM SomeTable INNER JOIN WHOSampleNo ON
SomeTable.Survey
> =
> > > > SampleNo.SurveyN " _
> > > > & "Where (((SomeTable.LabID) = " & LabID & ") AND
> > > > ((SomeTable.Survey)<= " & sSurvey & ")) " _
> > > > & "ORDER BY SomeTable.Survey"
> > > >
> > > > rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> > > > Set rsGeneric.ActiveConnection = Nothing
> > > > strSQL = ""
> > > >
> > > > If rsGeneric.RecordCount > 0 Then
> > > > With rsGeneric
> > > > .MoveFirst
> > > > Do While Not .EOF
> > > >
> > > > ReagentID = !ReagentID
> > > > WHOSurvey = !Survey
> > > >
> > > > 'here I save the data that matches my criteria
> > > >
> > > > If RsResult.RecordCount > 0 Then
> > > > With NewRS
> > > > 'Push into a new recordset
> > > > .AddNew
> > > > !LabID = RsResult!LabID
> > > > !Survey = RsResult!Survey
> > > > !Dev = (Format(RsResult![Dev], "###0.00"))
> > > > .Update
> > > > .MoveNext
> > > > End With
> > > > Set RsResult = Nothing
> > > > >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
> > > >
> > > >
> > > > ELSE
> > > >
> > > > ....Some other action
> > > > .....
> > > > ...
> > > > End If
> > > > Loop
> > > > etc
> > > >
> > > > <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
> > > >
> > > > 'Query the recordset (NewRs) obtained from above and do something
with
> > it.
> > > >
> > > > strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio "
_
> > > > & "FROM NewRs " _
> > > > & "ORDER BY NewRs.Survey ASC"
> > > > RsResult.Open strSQL, cnNEQAS, , , adCmdText
> > > > Set RsResult.ActiveConnection = Nothing
> > > > strSQL = ""
> > > >
> > > > Obviously, here I get an error that states that there is no table or
> > query
> > > > called NewRS in the database
> > > > .........................
> > > >
> > > > How do I query this NewRs please?
> > > >
> > > >
> > > > Thank you for any help that you can give me.
> > > >
> > > > Best regards
> > > >
> > > > David clifford
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
> >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Feb 25, 2005 Posts: 2
|
(Msg. 6) Posted: Fri Feb 25, 2005 8:17 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
What about using MSDataShaping? Sounds like this is what you are looking for:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado27...tm/mdms
Quote:
"Data shaping means building hierarchical relationships between two or more
logical entities in a query. The hierarchy can be seen in parent-child
relationships between a record of one Recordset, and one or more records
(also known as a chapter) of another Recordset."
"David Clifford" wrote:
> OK, temp table it is. I have used the Select Into statement quite a bit
> before. Still, pity it can't be done more eloquently and directly from the
> query recordset though. Thank you very much for your input and time.
>
> Best reards.
>
> David Clifford
>
> "Veign" wrote in message
>
> > More flexibility with the ability to use SQL...
> >
> > Look into the SELECT INTO statement;
> >
> > I have a SQL Reference guide in my Application Dev Resource Area that show
> > examples of the SELECT INTO.
> >
> > --
> > Chris Hanscom - Microsoft MVP (VB)
> > Veign's Resource Center
> > http://www.veign.com/vrc_main.asp
> > --
> >
> > "David Clifford" wrote in message
> >
> > > Hummm..thanks for that information Chris...I'm not too sure that it
> would
> > > accomplish what I am looking for though. Are you saying that it would
> > > probably be better to write the whole lot to a temp table in the first
> > > place?
> > >
> > > Best regards.
> > >
> > > David Clifford
> > >
> > > "Veign" wrote in message
> > >
> > > > The best you would be able to do is use the Find or Filter methods of
> > the
> > > > recordset - note both are limiting..
> > > >
> > > > Find:
> > > > http://www.devguru.com/Technologies/ado/quickref/recordset_find.html
> > > >
> > > > Filter:
> > > > http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html
> > > >
> > > >
> > > > --
> > > > Chris Hanscom - Microsoft MVP (VB)
> > > > Veign's Resource Center
> > > > http://www.veign.com/vrc_main.asp
> > > > --
> > > >
> > > > "David Clifford" wrote in message
> > > >
> > > > > Hello all.
> > > > >
> > > > > This is such a basic question, but I can't find an answer.
> > > > >
> > > > > I have a function in a class module that finds data from a series of
> > > > > database tables. The data, when found, is placed into a new
> recordset
> > > > within
> > > > > the function. All OK here.
> > > > > Now, where I am stuck is how do I make a query from this query?
> > > > >
> > > > > For example, I have my new recordset in my function that contain all
> > of
> > > > the
> > > > > data that I have extracted from the database tables, now I want to
> > > search
> > > > > that recordset for a further sub set of data, that is where I am
> > stuck.
> > > > OK,
> > > > > I could bung it all into a temporary table, but that will hit the
> > > > > performance of my app. So I thought of querying the query instead
> > > > >
> > > > > A snippet of code to illustrate follows:
> > > > >
> > > > > 'In a class module
> > > > >
> > > > > Public Function Some_Function(strTable As String, strMedianTbl As
> > > String,
> > > > > strField As String, strPast As String, sSurvey As Integer, ByVal
> LabID
> > > As
> > > > > Long) As String
> > > > >
> > > > >
> > > > > Dim NewRS As New ADODB.Recordset
> > > > > Dim RsResult As New ADODB.Recordset
> > > > >
> > > > > Dim ReagentID As Integer 'The ReagentID for that survey
> > > > > Dim WHOSurvey As Integer 'The WHOSurvey for that survey
> > > > >
> > > > > ReagentID = 0
> > > > > WHOSurvey = 0
> > > > >
> > > > > With cnNEQAS
> > > > > .Open
> > > > > .CursorLocation = adUseClient
> > > > >
> > > > > With NewRS.Fields 'First define the fields of the new
> recordset
> > > > > .Append "LabID", adInteger, 4
> > > > > .Append "Survey", adInteger, 4
> > > > > .Append "Used", adVarChar, 7
> > > > > .Append "Dev", adSingle, 7
> > > > > End With
> > > > >
> > > > > With NewRS
> > > > > .Open
> > > > > End With
> > > > >
> > > > >
> > > > > strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
> > > > strPast
> > > > > & ", SomeTable.ReagentID " _
> > > > > & "FROM SomeTable INNER JOIN WHOSampleNo ON
> SomeTable.Survey
> > =
> > > > > SampleNo.SurveyN " _
> > > > > & "Where (((SomeTable.LabID) = " & LabID & ") AND
> > > > > ((SomeTable.Survey)<= " & sSurvey & ")) " _
> > > > > & "ORDER BY SomeTable.Survey"
> > > > >
> > > > > rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> > > > > Set rsGeneric.ActiveConnection = Nothing
> > > > > strSQL = ""
> > > > >
> > > > > If rsGeneric.RecordCount > 0 Then
> > > > > With rsGeneric
> > > > > .MoveFirst
> > > > > Do While Not .EOF
> > > > >
> > > > > ReagentID = !ReagentID
> > > > > WHOSurvey = !Survey
> > > > >
> > > > > 'here I save the data that matches my criteria
> > > > >
> > > > > If RsResult.RecordCount > 0 Then
> > > > > With NewRS
> > > > > 'Push into a new recordset
> > > > > .AddNew
> > > > > !LabID = RsResult!LabID
> > > > > !Survey = RsResult!Survey
> > > > > !Dev = (Format(RsResult![Dev], "###0.00"))
> > > > > .Update
> > > > > .MoveNext
> > > > > End With
> > > > > Set RsResult = Nothing
> > > > > >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
> > > > >
> > > > >
> > > > > ELSE
> > > > >
> > > > > ....Some other action
> > > > > .....
> > > > > ...
> > > > > End If
> > > > > Loop
> > > > > etc
> > > > >
> > > > > <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
> > > > >
> > > > > 'Query the recordset (NewRs) obtained from above and do something
> with
> > > it.
> > > > >
> > > > > strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio "
> _
> > > > > & "FROM NewRs " _
> > > > > & "ORDER BY NewRs.Survey ASC"
> > > > > RsResult.Open strSQL, cnNEQAS, , , adCmdText
> > > > > Set RsResult.ActiveConnection = Nothing
> > > > > strSQL = ""
> > > > >
> > > > > Obviously, here I get an error that states that there is no table or
> > > query
> > > > > called NewRS in the database
> > > > > .........................
> > > > >
> > > > > How do I query this NewRs please?
> > > > >
> > > > >
> > > > > Thank you for any help that you can give me.
> > > > >
> > > > > Best regards
> > > > >
> > > > > David clifford
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
> >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
External

Since: Feb 25, 2005 Posts: 2
|
(Msg. 7) Posted: Fri Feb 25, 2005 8:19 pm
Post subject: Re: ADO recordset question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Here is an example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado27...tm/mdho
"ld" wrote:
> What about using MSDataShaping? Sounds like this is what you are looking for:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado27...tm/mdms
>
> Quote:
> "Data shaping means building hierarchical relationships between two or more
> logical entities in a query. The hierarchy can be seen in parent-child
> relationships between a record of one Recordset, and one or more records
> (also known as a chapter) of another Recordset."
>
>
> "David Clifford" wrote:
>
> > OK, temp table it is. I have used the Select Into statement quite a bit
> > before. Still, pity it can't be done more eloquently and directly from the
> > query recordset though. Thank you very much for your input and time.
> >
> > Best reards.
> >
> > David Clifford
> >
> > "Veign" wrote in message
> >
> > > More flexibility with the ability to use SQL...
> > >
> > > Look into the SELECT INTO statement;
> > >
> > > I have a SQL Reference guide in my Application Dev Resource Area that show
> > > examples of the SELECT INTO.
> > >
> > > --
> > > Chris Hanscom - Microsoft MVP (VB)
> > > Veign's Resource Center
> > > http://www.veign.com/vrc_main.asp
> > > --
> > >
> > > "David Clifford" wrote in message
> > >
> > > > Hummm..thanks for that information Chris...I'm not too sure that it
> > would
> > > > accomplish what I am looking for though. Are you saying that it would
> > > > probably be better to write the whole lot to a temp table in the first
> > > > place?
> > > >
> > > > Best regards.
> > > >
> > > > David Clifford
> > > >
> > > > "Veign" wrote in message
> > > >
> > > > > The best you would be able to do is use the Find or Filter methods of
> > > the
> > > > > recordset - note both are limiting..
> > > > >
> > > > > Find:
> > > > > http://www.devguru.com/Technologies/ado/quickref/recordset_find.html
> > > > >
> > > > > Filter:
> > > > > http://www.devguru.com/Technologies/ado/quickref/recordset_filter.html
> > > > >
> > > > >
> > > > > --
> > > > > Chris Hanscom - Microsoft MVP (VB)
> > > > > Veign's Resource Center
> > > > > http://www.veign.com/vrc_main.asp
> > > > > --
> > > > >
> > > > > "David Clifford" wrote in message
> > > > >
> > > > > > Hello all.
> > > > > >
> > > > > > This is such a basic question, but I can't find an answer.
> > > > > >
> > > > > > I have a function in a class module that finds data from a series of
> > > > > > database tables. The data, when found, is placed into a new
> > recordset
> > > > > within
> > > > > > the function. All OK here.
> > > > > > Now, where I am stuck is how do I make a query from this query?
> > > > > >
> > > > > > For example, I have my new recordset in my function that contain all
> > > of
> > > > > the
> > > > > > data that I have extracted from the database tables, now I want to
> > > > search
> > > > > > that recordset for a further sub set of data, that is where I am
> > > stuck.
> > > > > OK,
> > > > > > I could bung it all into a temporary table, but that will hit the
> > > > > > performance of my app. So I thought of querying the query instead
> > > > > >
> > > > > > A snippet of code to illustrate follows:
> > > > > >
> > > > > > 'In a class module
> > > > > >
> > > > > > Public Function Some_Function(strTable As String, strMedianTbl As
> > > > String,
> > > > > > strField As String, strPast As String, sSurvey As Integer, ByVal
> > LabID
> > > > As
> > > > > > Long) As String
> > > > > >
> > > > > >
> > > > > > Dim NewRS As New ADODB.Recordset
> > > > > > Dim RsResult As New ADODB.Recordset
> > > > > >
> > > > > > Dim ReagentID As Integer 'The ReagentID for that survey
> > > > > > Dim WHOSurvey As Integer 'The WHOSurvey for that survey
> > > > > >
> > > > > > ReagentID = 0
> > > > > > WHOSurvey = 0
> > > > > >
> > > > > > With cnNEQAS
> > > > > > .Open
> > > > > > .CursorLocation = adUseClient
> > > > > >
> > > > > > With NewRS.Fields 'First define the fields of the new
> > recordset
> > > > > > .Append "LabID", adInteger, 4
> > > > > > .Append "Survey", adInteger, 4
> > > > > > .Append "Used", adVarChar, 7
> > > > > > .Append "Dev", adSingle, 7
> > > > > > End With
> > > > > >
> > > > > > With NewRS
> > > > > > .Open
> > > > > > End With
> > > > > >
> > > > > >
> > > > > > strSQL = "SELECT SomeTable.Survey, SomeTable.LabID, SampleNo." &
> > > > > strPast
> > > > > > & ", SomeTable.ReagentID " _
> > > > > > & "FROM SomeTable INNER JOIN WHOSampleNo ON
> > SomeTable.Survey
> > > =
> > > > > > SampleNo.SurveyN " _
> > > > > > & "Where (((SomeTable.LabID) = " & LabID & ") AND
> > > > > > ((SomeTable.Survey)<= " & sSurvey & ")) " _
> > > > > > & "ORDER BY SomeTable.Survey"
> > > > > >
> > > > > > rsGeneric.Open strSQL, cnNEQAS, , , adCmdText
> > > > > > Set rsGeneric.ActiveConnection = Nothing
> > > > > > strSQL = ""
> > > > > >
> > > > > > If rsGeneric.RecordCount > 0 Then
> > > > > > With rsGeneric
> > > > > > .MoveFirst
> > > > > > Do While Not .EOF
> > > > > >
> > > > > > ReagentID = !ReagentID
> > > > > > WHOSurvey = !Survey
> > > > > >
> > > > > > 'here I save the data that matches my criteria
> > > > > >
> > > > > > If RsResult.RecordCount > 0 Then
> > > > > > With NewRS
> > > > > > 'Push into a new recordset
> > > > > > .AddNew
> > > > > > !LabID = RsResult!LabID
> > > > > > !Survey = RsResult!Survey
> > > > > > !Dev = (Format(RsResult![Dev], "###0.00"))
> > > > > > .Update
> > > > > > .MoveNext
> > > > > > End With
> > > > > > Set RsResult = Nothing
> > > > > > >>>>>>>>>>ALL OK UP TO HERE<<<<<<<<<<<
> > > > > >
> > > > > >
> > > > > > ELSE
> > > > > >
> > > > > > ....Some other action
> > > > > > .....
> > > > > > ...
> > > > > > End If
> > > > > > Loop
> > > > > > etc
> > > > > >
> > > > > > <<<<<<<'HERE IS WHERE I AM STUCK>>>>>>>>
> > > > > >
> > > > > > 'Query the recordset (NewRs) obtained from above and do something
> > with
> > > > it.
> > > > > >
> > > > > > strSQL = "SELECT TOP 6 NewRs.Survey, NewRs.LabID, NewRs.Ratio "
> > _
> > > > > > & "FROM NewRs " _
> > > > > > & "ORDER BY NewRs.Survey ASC"
> > > > > > RsResult.Open strSQL, cnNEQAS, , , adCmdText
> > > > > > Set RsResult.ActiveConnection = Nothing
> > > > > > strSQL = ""
> > > > > >
> > > > > > Obviously, here I get an error that states that there is no table or
> > > > query
> > > > > > called NewRS in the database
> > > > > > .........................
> > > > > >
> > > > > > How do I query this NewRs please?
> > > > > >
> > > > > >
> > > > > > Thank you for any help that you can give me.
> > > > > >
> > > > > > Best regards
> > > > > >
> > > > > > David clifford
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> > >> Stay informed about: ADO recordset question |
|
| Back to top |
|
 |  |
| Related Topics: | updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..
ADODB.RecordSet - Hi, I have a client recordset returned via VB6. I'd like to know if it can be inserted to a phisical table on MS SQL SERVER containing the same fields...? It'd be like a "INSERT SELECT", but the source (select) would come from this adodb.rec...
Recordset-adding to a Listview - I've got a weird problem - - - it must be something simple, but for the life of me, I must be missing it... I've got a recordset - and I'm trying to add the results into a listview, but, instead of adding each successive record after the first line of....
VB6 using ADO, sproc with return recordset - VB6 code snippet: with cmd .cmdtext = "exec buildwordlist 11" .commandtype = adcmdtext end with set rs = cmd.execute() if not rs.eof then strfield = rs!fieldname rs.movenext end if the above code works just fine if the sproc is ...
Updating An ADO 2.6 Recordset With VB and Access - When I try to update my ADO Recordset like this: recSet.Fields(2).Value = strFileNum I get this: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. Error 3251 When I try t... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|