Solved

Using DCOUNT in Continuous SubForm (or similar)

Posted on 2014-02-26
4
713 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 38

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 48

Accepted Solution

by:
Dale Fye 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.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

623 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