Accessing a forms or subforms recordset from a text box. to be able to use DCount etc

  • Thread starter Thread starter Kevin Vaughan
  • Start date Start date
K

Kevin Vaughan

Hi y'all,
Does anyone know if it is possible to put a DCount into a text box on a form
with the DCount Recordset equalling the form's CURRENT recordset - not just
the one it is opened up with but the current one which may be filtered?

Or should I go about this in a different manner?

Thanks in anticipation.
Regards
Kevin Vaughan
 
When you turn the filter on and off, you will get an OnCurrent event for the form. In that
event, you could check the filter status of the form (on or off) and change the control
source of the control. You would apply the filter to the DCount's where part.

Are all of the values you are counting part of the form's recordset? If so, you may be
able to use

=Count([FieldName])

instead. This will auto adjust when you filter the form.
 
Kevin said:
Does anyone know if it is possible to put a DCount into a text box on a form
with the DCount Recordset equalling the form's CURRENT recordset - not just
the one it is opened up with but the current one which may be filtered?

No, DCount operates on a table or query, not a recordset.

What are you trying to count?
 
Thanks for your reply Marshall,
Among other things, I am trying to count how many FireVideoDates are less
than a year old. I want to display a percentage in a calculated text box in
the form footer after a user has filtered (usually by the Filter by
Selection button) on one of a number of choices eg Department being one. I
thought the Dcount would be the easiest method.
I am using Access 97 on an NT4 network.

Regards Kevin

Kevin said:
Does anyone know if it is possible to put a DCount into a text box on a form
with the DCount Recordset equalling the form's CURRENT recordset - not just
the one it is opened up with but the current one which may be filtered?

No, DCount operates on a table or query, not a recordset.

What are you trying to count?
 
Kevin said:
Among other things, I am trying to count how many FireVideoDates are less
than a year old. I want to display a percentage in a calculated text box in
the form footer after a user has filtered (usually by the Filter by
Selection button) on one of a number of choices eg Department being one. I
thought the Dcount would be the easiest method.
I am using Access 97 on an NT4 network.

Quite possibly you could use Wayne's ideas as a basis to do
this.

I think, depending on the specific details of what you want,
you may also be able to adapt his suggestion about using an
aggregate function. Maybe this will help flesh it out for
you - try using the Sum function in a text box:

=Sum(IIf(DateAdd("yyyy", 1, FireVideoDates) > Date(), 1, 0))

The total number of records in the form's filtered record
source is Count(*), so I think you can get your percentage
by dividing the Sum by the Count.

Not sure if that's what you really want to do, but maybe you
can get an idea from those examples.
 
Back
Top