×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ADO Data Objects - Sub Query as Source

ADO Data Objects - Sub Query as Source

ADO Data Objects - Sub Query as Source

(OP)
Suppose I have a query like this...

CODE

Select
  A.F1
, Sum(B.F1)
From Table1 A
,
(
Select
  F1
, F2
From Table2
) B
Where A.F2=B.F2
Group By A.F1
But I want to accomplish it with separate recordsets...

CODE

sSQL = "Select "
sSQL = sSQL & "  F1 "
sSQL = sSQL & ", F2 "
sSQL = sSQL & "From Table2 "

rst1.Open sSQL, cnn, adOpenForwardOnly

sSQL = "Select "
sSQL = sSQL & "  A.F1
sSQL = sSQL & ", Sum(B.F1)
sSQL = sSQL & "From Table1 A
sSQL = sSQL & ",
sSQL = sSQL & "(
'somehow use rst1 here.  I know I can use it like rst1.Source, but is there another method?

sSQL = sSQL & ") B
sSQL = sSQL & "Where A.F2=B.F2
sSQL = sSQL & "Group By A.F1

rst2.Open sSQL, cnn, adOpenDynamic
In reality, rst2 is a summary of rst1, and several other queries as well.

My objective is that after I post the resultset for rst2, I give the user the ability to drill down into rst1 and other detail resultsets that are summarized in rst2.

Skip,

glasses When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd!  and
Many are Cold, but Few are Frozen!tongue

RE: ADO Data Objects - Sub Query as Source

Not quite what you were after Skip, but I've seen this done in apps by only issuing code to execute rst1, then using recordset filters in Access or summary rows in Excel pivot tables to display the summary information.

You can then open the detail that the user requests without running a query to open the detail information.

John

RE: ADO Data Objects - Sub Query as Source

(OP)





Thanks, John.

Skip,

glasses When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd!  and
Many are Cold, but Few are Frozen!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close