Counter in subform but...


Ray C

I have a main form with a subform. The subform is in continuous form view.
In each row of this subform, I have a combo box where the user selects a
service. The user can select the same service for more than one record.

Next to the combobox, I need to add a read-only counter. This counter counts
the number of times a service is selected. For example, if I have three
records each having different services, then the counter must have the value
1 next to each combobox (because each service is selected once).

If I repeat a service twice, then for that one service I have the value 1 on
one record and the value 2 for the other record having that same service.

In other words, it's not a record counter but a counter for each service

How can I do this without having to make a query call to the database? Or
what would be the expression I would use for that textbox field.


John W. Vinson

How can I do this without having to make a query call to the database?

You can't, obviously, because the value in the textbox depends on data which
exists only in the database.

You could set the textbox's control source to

=NZ(DCount("*", "YourTableName", "[fieldname] = " & Me!combobox))

to count the number of records with the combo box value. You will need
additional criteria if you want to include other criteria (such as the form's
filter or master link field etc.)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question