Solved

Using DCOUNT in Continuous SubForm (or similar)

Posted on 2014-02-26
4
697 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 36

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

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…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

740 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