Re: Second Recordset?
From: Rob (emailme_at_somewhere_else.com)
Date: 05/20/04
- Next message: Joe: "Filter property of a recordset"
- Previous message: NIck: "Re: How do you Copy a record on a Form"
- In reply to: Tim: "Re: Second Recordset?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 19:35:04 +1000
Tim,
Have you created the two queries in design view? You can then use the
QueryDef object to create a recordset?
Cheers
Rob
"Tim" <anonymous@discussions.microsoft.com> wrote in message
news:f90401c43e27$86833950$a501280a@phx.gbl...
> Marshall,
>
> My problem can only be resolved by two queries. The
> second query select the record from the first query. I
> tried the query you stated but the output was different
> from my expected.
>
> Thanks anyway.
>
> Tim.
> >-----Original Message-----
> >Tim wrote:
> >>The following list all the info:
> >>
> >>Table3:
> >>
> >>Test ID Test Value
> >>99 aa
> >>99 aa
> >>98 ab
> >>98 ba
> >>97 cc
> >>96 aa
> >>96 aa
> >>96 cc
> >>95 cc
> >>95 cc
> >>95 cc
> >>1 c
> >>1 a
> >>
> >>
> >>Output:
> >>
> >>f1
> >>1
> >>96
> >>98
> >>
> >>Module:
> >>
> >>Public Sub test()
> >>Dim dbs As Database
> >>Dim rst1 As Recordset
> >>Dim rst2 As Recordset
> >>
> >>Set dbs = CurrentDb
> >>Set rst1 = dbs.OpenRecordset("SELECT DISTINCT [Test
> ID],
> >>[Test Value] FROM Table3;")
> >>
> >>Set rst2 = dbs.OpenRecordset("SELECT " & rst1.Fields
> >>("[Test ID]").Value & " as f1 FROM " & rst1 & _
> >> " GROUP BY " &
> >>rst1.Fields("[Test ID]").Value & _
> >> " HAVING Count(" &
> >>rst1.Fields("[Test ID]").Value & ") > 1;")
> >>
> >>Debug.Print rst2.Fields("f1").Value
> >
> >
> >I'm not sure I understand what you want here, but I
> >**think** you only need one query:
> >
> >SELECT [Test ID]
> >FROM table3
> >GROUP BY [Test ID], [Test Value]
> >HAVING Count(*) > 1
> >--
> >Marsh
> >MVP [MS Access]
> >.
> >
--- This email has been cetified virus free Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.688 / Virus Database: 449 - Release Date: 18/05/2004
- Next message: Joe: "Filter property of a recordset"
- Previous message: NIck: "Re: How do you Copy a record on a Form"
- In reply to: Tim: "Re: Second Recordset?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|