Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Count records in another table

Geek News

Count records in another table
Linda 12/11/2008 10:48:01 PM
I have a "Project Action" form with a button that opens another form, the
"Risk Form", using a DoCmd.OpenForm command. The records displayed in the
new form have an associated Project Action number that is the same as the
Project Action number in the calling form. The users would like the Project
Action form to indicate if any matching risk records exist without having to
actually open the risk form. How would I do that?
--
Linda
Re: Count records in another table
Rick Brandt <rickbrandt2[ at ]hotmail.com> 12/11/2008 11:59:46 PM
On Thu, 11 Dec 2008 14:48:01 -0800, Linda wrote:

[Quoted Text]
> I have a "Project Action" form with a button that opens another form,
> the "Risk Form", using a DoCmd.OpenForm command. The records displayed
> in the new form have an associated Project Action number that is the
> same as the Project Action number in the calling form. The users would
> like the Project Action form to indicate if any matching risk records
> exist without having to actually open the risk form. How would I do
> that?

You can use the DCount() to do this.

DCount("*", "TableName", "Where clause")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Re: Count records in another table
Linda 12/16/2008 5:16:25 PM
I created a text box on my Project Action form. In the record source I put
=DCount("*","Risk_Tracker","Assoc_PA_Num=Me.[SPR Number]")
where Risk_Tracker is the form I want to count records in.
Assoc_PA_Num is the field in the Risk_Tracker form that I want to equal the
value in the SPR Number field on the currently opened form.
I get a#Error in the text box.
What have I done wrong?
Thanks,
--
Linda


"Rick Brandt" wrote:

[Quoted Text]
> On Thu, 11 Dec 2008 14:48:01 -0800, Linda wrote:
>
> > I have a "Project Action" form with a button that opens another form,
> > the "Risk Form", using a DoCmd.OpenForm command. The records displayed
> > in the new form have an associated Project Action number that is the
> > same as the Project Action number in the calling form. The users would
> > like the Project Action form to indicate if any matching risk records
> > exist without having to actually open the risk form. How would I do
> > that?
>
> You can use the DCount() to do this.
>
> DCount("*", "TableName", "Where clause")
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>
Re: Count records in another table
Linda 12/17/2008 11:35:01 PM
My follow-up question wasn't right. Risk_Tracker is a table. I can't seem
to get a query right or the record source right to return the number of
records in the table that match the ID of the current record from the Project
Action record being displayed in the form. I either get a #Error or the
total number of records in the Risk_Tracker table. Can anyone clear this up
for me?
Thanks,
Linda
--
Linda


"Linda" wrote:

[Quoted Text]
> I created a text box on my Project Action form. In the record source I put
> =DCount("*","Risk_Tracker","Assoc_PA_Num=Me.[SPR Number]")
> where Risk_Tracker is the form I want to count records in.
> Assoc_PA_Num is the field in the Risk_Tracker form that I want to equal the
> value in the SPR Number field on the currently opened form.
> I get a#Error in the text box.
> What have I done wrong?
> Thanks,
> --
> Linda
>
>
> "Rick Brandt" wrote:
>
> > On Thu, 11 Dec 2008 14:48:01 -0800, Linda wrote:
> >
> > > I have a "Project Action" form with a button that opens another form,
> > > the "Risk Form", using a DoCmd.OpenForm command. The records displayed
> > > in the new form have an associated Project Action number that is the
> > > same as the Project Action number in the calling form. The users would
> > > like the Project Action form to indicate if any matching risk records
> > > exist without having to actually open the risk form. How would I do
> > > that?
> >
> > You can use the DCount() to do this.
> >
> > DCount("*", "TableName", "Where clause")
> >
> > --
> > Rick Brandt, Microsoft Access MVP
> > Email (as appropriate) to...
> > RBrandt at Hunter dot com
> >

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net