Share via

Create count using different tables in access

Anonymous
2018-04-04T13:00:56+00:00

I have a sessions table with a field called capacity and a scheduling table with a session field. When a session is scheduled I need to be able to subtract one from the capacity in the sessions table and keep it in a field called available (10 of 20) in the sessions table. When the session capacity is reached (20 of 20), I would like the field to turn red so it is known the session is full. Has anyone done this before and how would I go about it?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-04-04T16:18:27+00:00

I wouldn't use table calculated fields AT ALL; they're very limited and not necessary. I also would not expose your Table datasheets to view; they should be "under the hood", and all your interaction with the data should be done using a Form. The calculation can be done in a Query used as the Form's Recordsource, or with expressions like =DCount("*", ...) in the Control Source of a textbox on the Form.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

Answer accepted by question author

Duane Hookom 26,825 Reputation points Volunteer Moderator
2018-04-04T14:39:38+00:00

Typically you don't want or need to store the available value since it can be calculated on the fly. You can use DCount()

=DCount("*","Sessions","[Session ID] = " & [Session ID]) & " of " & [Session Capacity]

This assumes there is a numeric [Session ID] field in both tables.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-04-04T16:04:07+00:00

    What type of field do I use? The expression DCOUNT cannot be used in a calculated field.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-04-04T14:57:23+00:00

    Will this work with the user choosing the session id from a drop down in the scheduling table?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-04-04T14:27:31+00:00

    I found how this is done in Excel:

    Total Scheduled = IF(Reservation date=",",COUNTIF(Scheduling!Session ID:Session ID,Session number)& " of " & Session Capacity)

    Does this help?

    Was this answer helpful?

    0 comments No comments