DCount function

  • Thread starter Thread starter lynn atkinson
  • Start date Start date
L

lynn atkinson

I want to work out how many places are booked or
provisionally booked on a course. The bookings are
displayed in a subform for each course. I want to display
how many places have been taken up on a particular course.
I have eventually got DCount to count how many entries are
booked or provisional on the subform (ie all bookings for
all courses).
How do I get this to relate to the individual courses. The
form and subform are linked by the course ID and therefore
the subform only displays the participants for that
particular course.
However, the DCount calculation I got to work on the
subform, displays the total booked, not the number booked
for that course.
I hope this explains my query clearly enough!

PS I have searched the newsgroup for similar questions,
but am having difficulty relating them to my situation.
 
It would be helpful if you would post the DCount statement
that you have written that produce the results indicated in
your message and also the names of the fields that provide
the link between Form and SubForm.

Thanks

Gerald Stanley MCSD
 
The statement is as follows (it only looks for 'booked'
status as I have not worked out how to find 'booked or
provisional'!)

=DCount("[bookings]![status]","bookings","[bookings]!
[status]='booked'")

This statement counts all the records which have status
as 'booked' in the subform which lists all the bookings
for all the courses.

The fields that provide the links between form and subform
is EventID.
Does this help?
 
I assume that you have the EventId on the Form. The DCount
statement should look something like

=DCount("[status]","bookings","[eventId] = " &
Forms!{yourFormName}![eventId] & " AND [status] IN
('booked','provisional')")

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
The statement is as follows (it only looks for 'booked'
status as I have not worked out how to find 'booked or
provisional'!)

=DCount("[bookings]![status]","bookings","[bookings]!
[status]='booked'")

This statement counts all the records which have status
as 'booked' in the subform which lists all the bookings
for all the courses.

The fields that provide the links between form and subform
is EventID.
Does this help?
-----Original Message-----
It would be helpful if you would post the DCount statement
that you have written that produce the results indicated in
your message and also the names of the fields that provide
the link between Form and SubForm.

Thanks

Gerald Stanley MCSD
.
.
 
You probably need to extend the criteria of your dcount statement to include
the EventID. If your form has a control that holds that value when the
dcount statement is executed, you would add it to the dcount statement like
this:

=DCount("[bookings]![status]", "bookings", "[bookings]![status]='booked' and
[EventID]='" & MyFormCtrlValue & "'")
Note the single and double quotes after EventID]= and before the right
parenthesis.

I expect this will work.

Personally, I have never understood what the first parameter is for. It
seems like all my dcount references return the same value no matter what I
put there, so I have just simplified things by putting a 1 there, like this:
dcount(1,"domain","[field]='" & value & "'")

Maybe someone can shed light on the significance of the "expression" part of
the function for me.

Hope this helps.
Paul Johnson

lynn atkinson said:
The statement is as follows (it only looks for 'booked'
status as I have not worked out how to find 'booked or
provisional'!)

=DCount("[bookings]![status]","bookings","[bookings]!
[status]='booked'")

This statement counts all the records which have status
as 'booked' in the subform which lists all the bookings
for all the courses.

The fields that provide the links between form and subform
is EventID.
Does this help?
-----Original Message-----
It would be helpful if you would post the DCount statement
that you have written that produce the results indicated in
your message and also the names of the fields that provide
the link between Form and SubForm.

Thanks

Gerald Stanley MCSD
.
 
Back
Top