Re: Second Recordset?
From: Tim (anonymous_at_discussions.microsoft.com)
Date: 05/20/04
- Next message: John Vinson: "Re: Replacing data"
- Previous message: Ken Snell: "Re: Return message based on query result"
- In reply to: Marshall Barton: "Re: Second Recordset?"
- Next in thread: Rob: "Re: Second Recordset?"
- Reply: Rob: "Re: Second Recordset?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 May 2004 22:01:35 -0700
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]
>.
>
- Next message: John Vinson: "Re: Replacing data"
- Previous message: Ken Snell: "Re: Return message based on query result"
- In reply to: Marshall Barton: "Re: Second Recordset?"
- Next in thread: Rob: "Re: Second Recordset?"
- Reply: Rob: "Re: Second Recordset?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|