Not sure if this can be done?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

What I woudl liek to do is have a field on a form (not linked to any
datasource) which shows how many records in a table have a certain parameter
(in this case if a yes/no field is yes)

So basically I want the field to show a number indicating how many records
have a field with the value yes.

I pressume I would need to run some VB onopen of the form?

Is this possible?

Cheers,
Andrew
 
FollanA said:
Hi all,

What I woudl liek to do is have a field on a form (not linked to any
datasource) which shows how many records in a table have a certain
parameter (in this case if a yes/no field is yes)

So basically I want the field to show a number indicating how many
records have a field with the value yes.

I pressume I would need to run some VB onopen of the form?

Is this possible?

Cheers,
Andrew

It's possible, and you don't need to write any VB code. You can use the
DCount function in the controlsource of the text box to do this. It
would look something like ...

=DCount("*", "YourTableName", "YourField=True")

.... where "YourTableName" is the name of the table in which you want to
count records, and "YourField" is the name of your Yes/No field. If the
field name contains spaces or other nonstandard characters, enclose it
in square brackets:

=DCount("*", "YourTableName", "[YourField]=True")
 
Hi Dirk,

Thanks for the reply it worked well.

In addition though how would I customise the Dcount function so it works off
a query (not sure if that is what I need to do?)

My current function is:
=DCount("*","[TBL_requests]","[to_display_as_new]=True")

This shows the number of records where the field to_display_as_new is marked
as "Yes". What I now need to do is have another field show the same as above
BUT also if another field (updated) is marked "yes". I thought something like
below but it didn't work:

=DCount("*","[TBL_requests]","[to_display_as_new]=True" AND "[updated]=True")

Thanks in advance :)

Andrew
 
you're close. try

=DCount("*","[TBL_requests]","[to_display_as_new]=True AND [updated]=True")

all on one line, of course.

hth


FollanA said:
Hi Dirk,

Thanks for the reply it worked well.

In addition though how would I customise the Dcount function so it works off
a query (not sure if that is what I need to do?)

My current function is:
=DCount("*","[TBL_requests]","[to_display_as_new]=True")

This shows the number of records where the field to_display_as_new is marked
as "Yes". What I now need to do is have another field show the same as above
BUT also if another field (updated) is marked "yes". I thought something like
below but it didn't work:

=DCount("*","[TBL_requests]","[to_display_as_new]=True" AND "[updated]=True")

Thanks in advance :)

Andrew

Dirk Goldgar said:
It's possible, and you don't need to write any VB code. You can use the
DCount function in the controlsource of the text box to do this. It
would look something like ...

=DCount("*", "YourTableName", "YourField=True")

.... where "YourTableName" is the name of the table in which you want to
count records, and "YourField" is the name of your Yes/No field. If the
field name contains spaces or other nonstandard characters, enclose it
in square brackets:

=DCount("*", "YourTableName", "[YourField]=True")
 
FollanA said:
Hi Dirk,

Thanks for the reply it worked well.

In addition though how would I customise the Dcount function so it
works off a query (not sure if that is what I need to do?)

My current function is:
=DCount("*","[TBL_requests]","[to_display_as_new]=True")

This shows the number of records where the field to_display_as_new is
marked as "Yes". What I now need to do is have another field show the
same as above BUT also if another field (updated) is marked "yes". I
thought something like below but it didn't work:

=DCount("*","[TBL_requests]","[to_display_as_new]=True" AND
"[updated]=True")

See tina's response.
 
Back
Top