Re: Limit Report to the 1st 30 records
- From: "Blair" <bemullen@@@ns.sympatico.ca>
- Date: Tue, 11 Apr 2006 10:54:59 -0300
Thanks for your help, I to have a busy day and won't get a chance to check
it out till to night,
thanks again Blair
"John Spencer" <spencer@xxxxxxxxx> wrote in message
news:%23y0g12WXGHA.128@xxxxxxxxxxxxxxxxxxxxxxx
You can try the query below. I have no way to test it. I suggest youpaste
it into a new query. If you get an error, please post the error messageday
back to the group. I'll try to check back later today, but it's a busy
today and I may not get back. If not, perhaps Tom Ellison will look overtogether,
our shoulders and post something more elegant (or at least point out my
error).
Assumptions:
You have a control on the form with the name
[Forms]![FFirstMating]![txtGetNumber]
You don't need to show the ranking.
SELECT
[98MatingRecords].[SHED #]
, [98MatingRecords].[NEST #]
, [98MatingRecords].Section
, [98MatingRecords].[FEMALE #]
, [98MatingRecords].[Mating Year]
, [98MatingRecords].[1st MATING]
, [98FemaleHistory].Dead
FROM 98FemaleHistory INNER JOIN 98MatingRecords
ON [98FemaleHistory].[FEMALE #] = [98MatingRecords].[FEMALE #]
WHERE [98MatingRecords].[SHED #]=[Forms]![FFirstMating]![Text20] AND
[98MatingRecords].Section=[Forms]![FFirstMating]![Text22] AND
[98MatingRecords].[Mating Year]=Year(Now()) AND
[98MatingRecords].[1st MATING] Is Null AND
[98FemaleHistory].Dead=No
AND 1 +
(SELECT Count(*)
FROM 98FemaleHistory As F INNER JOIN 98MatingRecords as M
ON [F].[FEMALE #] = [M].[FEMALE #]
[M].[SHED #]=[Forms]![FFirstMating]![Text20] AND
[M].Section=[Forms]![FFirstMating]![Text22] AND
[M].[Mating Year]=Year(Now()) AND
[M].[1st MATING] Is Null AND
[F].Dead=No AND
[M].[Nest #] < [98MatingRecords].[NEST #])
<= CLng([Forms]![FFirstMating]![txtGetNumber] )
ORDER BY [98MatingRecords].[NEST #];
"Blair" <bemullen@@@ns.sympatico.ca> wrote in message
news:OXrRFkWXGHA.3760@xxxxxxxxxxxxxxxxxxxxxxx
Here is the SQL
Primary key in [98MatingRecords] is [Female #] and [Mating Year]
ANDIn [98FemaleHistory] it is [Female #] only
SELECT TOP 30 [98MatingRecords].[SHED #], [98MatingRecords].[NEST #],
[98MatingRecords].Section, [98MatingRecords].[FEMALE #],
[98MatingRecords].[Mating Year], [98MatingRecords].[1st MATING],
[98FemaleHistory].Dead
FROM 98FemaleHistory INNER JOIN 98MatingRecords ON
[98FemaleHistory].[FEMALE
#] = [98MatingRecords].[FEMALE #]
WHERE ((([98MatingRecords].[SHED #])=[Forms]![FFirstMating]![Text20])
are(([98MatingRecords].Section)=[Forms]![FFirstMating]![Text22]) AND
(([98MatingRecords].[Mating Year])=Year(Now())) AND
(([98MatingRecords].[1st
MATING]) Is Null) AND (([98FemaleHistory].Dead)=No))
ORDER BY [98MatingRecords].[NEST #];
Thanks Blair
"John Spencer" <spencer@xxxxxxxxx> wrote in message
news:Ohxe6WWXGHA.3440@xxxxxxxxxxxxxxxxxxxxxxx
No, you can't use a parameter to change the TOP nn. You would have to
use
VBA to rewrite the query.
An alternative would be to use a ranking query. That could use the
parameter (a reference to a control) but it would be slower. If you
Iinterested in that please post the SQL of your current query. Perhaps
andor
someone else, can then modify it. Also, tell us the name of the form
usecontrol that will contain the value you want to use to limit the recordand
identify the primary key field in your table(s).
(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message
"Blair" <bemullen@@@ns.sympatico.ca> wrote in message
news:e2gCnOWXGHA.3848@xxxxxxxxxxxxxxxxxxxxxxx
I used The top property and it works great, Thanks
Now I tried to put a form text box control but I can't, I can only
thea
number greater than zero. Is there an easy way to be able to change
number using a text box?
Thanks Blair
.
- References:
- Re: Limit Report to the 1st 30 records
- From: Blair
- Re: Limit Report to the 1st 30 records
- From: John Spencer
- Re: Limit Report to the 1st 30 records
- From: Blair
- Re: Limit Report to the 1st 30 records
- From: John Spencer
- Re: Limit Report to the 1st 30 records
- Prev by Date: Re: Limit Report to the 1st 30 records
- Next by Date: Zero's in reports
- Previous by thread: Re: Limit Report to the 1st 30 records
- Next by thread: Re: Limit Report to the 1st 30 records
- Index(es):
Relevant Pages
|