Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using DCOUNT in Continuous SubForm (or similar)

Posted on 2014-02-26
4
Medium Priority
?
752 Views
Last Modified: 2014-03-04
Hi,

I have a continuous subform that has a text field in it.  This text field is set to ;
=DCount("[CustomerNumber]", "tblOrders", "[CustomerNumber] = 888")


The DCOUNT bit works fine!

However,  for example, if there are 4 records shown in the continuous form then ALL of them have there text field updated.

I (obviously) ONLY want ONE record of the sub form updated.  I.e. the record that I have just amended.

Perhaps, you have seen this issue before?
0
Comment
Question by:Patrick O'Dea
  • 2
4 Comments
 
LVL 40

Assisted Solution

by:PatHartman
PatHartman earned 1000 total points
ID: 39889219
Access maintains only a single set of form properties.  That is why in a continuous or datasheet view, all instances of an unbound control show the same value.

We need to know more about what you are trying to count to advise further.  It is possible to use DCount() in a query although I don't recommend it.  If you use it in the query, you will be able to bind the control to a column from the query and so each row can show a different value.
0
 

Author Comment

by:Patrick O'Dea
ID: 39889928
Thanks for the help so far.

I attach a simple example.

1. There are 4 cities in tblCity.

2. I am monitoring cars (!) in the city.  I am writing the registration plate of each car seen in the city.  These registration numbers are help in tblCarsSpotted.

3. You will note that car reg L999 J120 has been seen in more than one city!

4. I want to see in the yellow box the NUMBER of cities that each car has been seen.

5. For example, the number 3 should appear in the yellow box for every occurrence of registration L999 J120.


How do I achieve item number 5?
CarsTemp.accdb
0
 
LVL 49

Accepted Solution

by:
Dale Fye earned 1000 total points
ID: 39901044
Working from iPad, so cannot open your file.

Does the resulting recordset (the one shown in your continuous form) need to be updateable?

If not you could create a subquery:

SELECT [Registration], COUNT([City]) as CitiesSeenIn
FROM (SELECT DISTINCT [Registration], [City] FROM tblCarsSpotted) as DistinctSpotings

And then join this to your Cars table on the Registration field.
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39904745
Thanks folks.
I have decided not to use this function after all.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question