Solved

Using DCOUNT in Continuous SubForm (or similar)

Posted on 2014-02-26
4
657 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 34

Assisted Solution

by:PatHartman
PatHartman earned 250 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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now