473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

DCount issues.... again

Hello everyone

I have been useing Access for a while now and have attempted useing DCount a number of times but with varying results.

I am currently trying to have a field in a form that will show how many times a particular address has been entered already and has a record in a table. So i was hoping that when the user enters an address the DCount field will show how many times it has already been entered into the table. The following code was used to to no avail

=DCount("Contamination2!Enq","Contamination2","Con tamination2!JoinedAddress=Forms![Contaminated Inpu]![joinedaddress]")

Contamination2 = Table
Contamination2!Enq = field to count (although i beleive this can change to any field in the table?)
Forms![Contaminated Inpu]![joinedaddress] = the filed on the form i want to use as the criteria.

Thanks in eager anticipation.....
Jun 23 '08 #1
16 1912
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. =DCount("*", "Contamination2", "[JoinedAddress] = '" & Forms![Contaminated Inpu]![joinedaddress] & "'")
NOTE: Be advised that it is nearly impossible to return all matches for addresses in the manner you specify, since there are many variations, e.g. there would not be a single match on any of the following addresses:
Expand|Select|Wrap|Line Numbers
  1. 1313 Mockingbird Lane
  2. 1313 Mockingbird Ln
  3. 1313 Mockingbird Ln.
  4. 1313 Mockingbird La
  5. 1313 Mockingbird La.
  6. 1313 Mockingbrd Lane
  7. 1313 Mockngbird La.
  8. atc.
  9. atc.
  10. etc.
  11. ...
Jun 23 '08 #2
Thanks for that

I have already realised this and have used various functions to ensure as much conformity as possible. all capital letters for example.
Jun 24 '08 #3
ADezii
8,834 Expert 8TB
Thanks for that

I have already realised this and have used various functions to ensure as much conformity as possible. all capital letters for example.
Capitalization is not the consideration, since all 4 Expressions below will yield the same results in the Northwind Database, namely 5.

'all yield 5
Expand|Select|Wrap|Line Numbers
  1. ? DCount("*", "Employees", "[Region] = 'WA'")
  2. ? DCount("*", "Employees", "[Region] = 'wa'")   
  3. ? DCount("*", "Employees", "[Region] = 'Wa'")
  4. ? DCount("*", "Employees", "[Region] = 'wA'")
Jun 24 '08 #4
I see. i suppose a little encouragement to the users to input uniform data may be my best hope?

I need to develop the DCount function a little more by counting how many times a letter has been sent for the address in the text box. So useing the DSCount solution from above the addition maybe somthing like this:

=DCount("[Repeatoffletter] = Yes","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "'")

Any ideas??
Jun 25 '08 #5
ADezii
8,834 Expert 8TB
I see. i suppose a little encouragement to the users to input uniform data may be my best hope?

I need to develop the DCount function a little more by counting how many times a letter has been sent for the address in the text box. So useing the DSCount solution from above the addition maybe somthing like this:

=DCount("[Repeatoffletter] = Yes","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "'")

Any ideas??
An Address should 'never' be listed more than once for a given User unless he/she has multiple residences, which would then be in a related Table. The number of Letters and related info such as: Date Sent, Content, Confirmation, etc. can be contained in a related Table in a MANY ==> 1 Relationship with the User info Table. Make sense?
Jun 25 '08 #6
hmmm, i think i get you. The only problem is, i will be adding 60 or so new or already recorded addresses everyday. So im not sure how to work it all.

each day i will be given a list of address that have a contaminated waste bin. I want to be able to each day input the address and as i do this a text box will show how many times the address has already been entered and how many times a specific letter has been sent to that address.

Sorry if im sounding super novice by the way.
Jun 25 '08 #7
ADezii
8,834 Expert 8TB
hmmm, i think i get you. The only problem is, i will be adding 60 or so new or already recorded addresses everyday. So im not sure how to work it all.

each day i will be given a list of address that have a contaminated waste bin. I want to be able to each day input the address and as i do this a text box will show how many times the address has already been entered and how many times a specific letter has been sent to that address.

Sorry if im sounding super novice by the way.
I still feel as though checking for duplicate Addresses in this manner is totally inefficient, and will also lead to erroneous results. Is there some Unique Identifier that specifically points to a User/Organization?

If you still insist on this approach, you will probably be better off querying the Table for Partial Matches in the [Address] Field, as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Employees
  3. WHERE Employees.Address Like "*" & [Enter Partial Address] & "*";
Positive: If you would plug in the partial criteria of 1313 when prompted, all entries in Post #2 would be returned. You would have a visual indication of Addresses meeting your Partial Search Criteria.

Negative: also returned would be the following Addresses:
Expand|Select|Wrap|Line Numbers
  1. 1313 Mulberry Drive
  2. 496 River Road, Apt. 1313
  3. 13134 Southhampton Road
  4. etc...
Jun 25 '08 #8
The database is designed to cater for all addresses in a city wide area. So to have a unique identity for all 140,000 odd addresses in the city artea would require alot of data entry effort on my part. Also, not all address will have to appear in the database. All that i record at the moment is a record of a contamination. so each contamination is unique. This means i do not have to have a seperate table with each address in the city. I understand that searching for matching addresses this was may cause odd results but i feel there are a few things you can do to reduce that chance. mainly ensuring uniformity when entering the data but obviously this is not alwasy possible.

Either way, although i greatly appreciate the help you are giving me. i really would appreciate an answer to the original question stated above with regards to DCount.

so to count the number of times a letter has been send for the address which is displayed in the text box on the form.

thanks (humble)
Jun 26 '08 #9
i have a further perhaps more complicated question for you........

Do you know of a way tp set the value of a check box depending on the date?

to explain. where i work our vehicles are set to work areas of a city in a sequence over two weeks. This means that one week they will work in certina areas and this is called A week. Next week they will work in different areas and this is called B week.

I want to be able to do this so that from the date a check box on the switchboard will change each week to represent A week or B week.

I dont want to have to create a huge table for dates going on far into the future. i simply want to set say this week as A and then access will automatically know that next week it will be B.

This may be a long shot and i realise it has nothing to do with the forum thread, but any input would be lovely.
Jun 26 '08 #10
sierra7
446 Expert 256MB
You can use Format(Date(),"ww") to return the Week Number.

You could then test whether it was Odd or Even (divide by two and see if there is a remainder), then perhaps proceed on that basis.

S7
Jun 26 '08 #11
sierra7
446 Expert 256MB

....... i really would appreciate an answer to the original question stated above with regards to DCount.
Your original DCount statement did not work because of your syntax in the statement. You need to concatonate the criteria to the parameter(s) you are matching, using ampersand (&) as in ADezii's first reply. You cant just use an equals sign unless you are literally specifying the parameter e.g. 'New York'. Note, he has also introduced single quotes because you are trying to match on a string not a number.

I have only briefly reviewed your task (ADezii has more than covered the reasons for not to proceed as you are doing) Can you use Post Code (Zip Code) to achieve your 'count'? I don't know the nature of your task but it seems to me that if your incidents were grouped by post code you could then browse them to see if they were the same address or not.

Clusters of incidents within an area might have more significance than individual addresses, maybe??

S7
Jun 26 '08 #12
ADezii
8,834 Expert 8TB
Your original DCount statement did not work because of your syntax in the statement. You need to concatonate the criteria to the parameter(s) you are matching, using ampersand (&) as in ADezii's first reply. You cant just use an equals sign unless you are literally specifying the parameter e.g. 'New York'. Note, he has also introduced single quotes because you are trying to match on a string not a number.

I have only briefly reviewed your task (ADezii has more than covered the reasons for not to proceed as you are doing) Can you use Post Code (Zip Code) to achieve your 'count'? I don't know the nature of your task but it seems to me that if your incidents were grouped by post code you could then browse them to see if they were the same address or not.

Clusters of incidents within an area might have more significance than individual addresses, maybe??

S7
The syntax in Post #2 would be correct, just make the necessary Field substitutions.
Jun 26 '08 #13
Thanks for all that but im still having issues with the latest DCount problem. namely

=DCount("[Repeatoffletter] = Yes","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "'")

i want to count how many times the address shown has the repeatofletter check box ticked. The above code does not work. it returns the number of times that address has been entered not how many times the check box has been ticked.
Jul 3 '08 #14
sierra7
446 Expert 256MB
Thanks for all that but im still having issues with the latest DCount problem. namely

=DCount("[Repeatoffletter] = Yes","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "'")

i want to count how many times the address shown has the repeatofletter check box ticked. The above code does not work. it returns the number of times that address has been entered not how many times the check box has been ticked.
Try;
=DCount("[Repeatoffletter]","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "' and [Repeatoffletter] = True")


S7
Jul 3 '08 #15
Try;
=DCount("[Repeatoffletter]","Contamination2","[JoinedAddress] = '" & [Forms]![Contaminated Inpu]![joinedaddress] & "' and [Repeatoffletter] = True")


S7

hmmm, this now returns "-1" any ideas?
Jul 4 '08 #16
woops, as you may have guessed, im prone in making errors. the code you gave me works great as long as you dont paste it in twice. thanks...
Jul 4 '08 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
1
by: Megan | last post by:
Hi Everybody- I've been reading some of the posts about DCOUNT, and I haven't yet found an answer; so, I'm posting this question. I have a report that I'm trying to use DCOUNT on to compute...
4
by: Will | last post by:
Hi, I had a DCount within a module on records in a table where CustSuffix = 0. I now need to DCount where CustSuffix = 0 and the type of cost Suffix (Suffix in table) = G. I can't get both...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
5
by: Sheldon Mopes | last post by:
I posted this about a week ago, and I got some interesting responses, but none of them acually answered what I was asking, so I'll try again.. I have read a few articles that state that a...
4
by: Michael R | last post by:
I have what seems to me a strange problem. I have a continous form, toggle buttons of a field, a text control, and a command's button caption. When I write the following in the text control's...
36
by: bmyers | last post by:
Good afternoon, I am attempting to count only those records within a report, which is based on a query, where Status is equal to Closed. I have tried multiple variations of DCOUNT but am...
8
by: Susan Bricker | last post by:
I have used DCount() to determine the number of records in a recordset. Silly me ... I just noticed that DCount returns an INTEGER, which can hold a maximum value of 32,767. What if the recordset...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.