Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2010, 11:26 AM
Authorized User
 
Join Date: Nov 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default simple question about counting

hi
i am using access 2010
i have 3 fields, phone_num , problem , count

i want the count field to start counting duplicated phone_num like '555111' num duplicated 3 times, 5 times and so on....

and if count is > 5 then change the font color of the duplicated record

please help
thnx
 
Old November 8th, 2010, 01:58 PM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Firstly don't use count as a field name it is a reserved word, use something like PhoneNumCount. Also, you don't have any uniqueness in your records so I guess you haven't got a primary key since you are allowing duplicates, however not knowing exactly what you are trying to achieve I can't give you any advice.

Are you wanting to store the 'PhoneNumCount' at the time the record is created OR do you just need a count of the number of problems recorded for each phone number, because if the latter you do not need to have a field in your table, this should be obtained using an aggregate query OR using DCount.

You don't give a name for your table so I'll assume it's PhoneProblems.

I think DCount will be the easiest option for you, if you are storing the value, you will need to put the following code in the AfterUpdate event of the phone_num control:
Code:
Me.PhoneNumCount = DCount("phone_num", "PhoneProblems", "phone_num = '" & [phone_num] & "'")
Depending on what you want, you may want to add 1 to this value, as this returns the number of records that already exist with the phone number you have just entered for this new record. This is setting the control which is bound to the 'count' field, which should be read only. When the record is saved the count will be saved too.

If you're not saving the count then just put the DCount formula in the control source of your 'count' control.

On your form that displays your records you then need to create some conditional formatting. For each control on your record since you said you want the whole record to change font colour, select Conditional Formatting, select Expression Is and enter [PhoneNumCount]>5.

HTH. Maybe a poor explanantion so if you have any issues post back.

Malc.
 
Old November 8th, 2010, 07:03 PM
Authorized User
 
Join Date: Nov 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
thnx for your replay...
i work in customer service, i answer the phone and solve their problem, so i am trying to make a database, typing their phone number and their problem... if i typed their number again it will starting counting how many times i typed their number....


thnx alot of your reply
 
Old November 8th, 2010, 07:38 PM
Authorized User
 
Join Date: Nov 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

couldnt solve it,,, help me plz
 
Old November 10th, 2010, 12:26 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Did you ever get this working?
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old November 11th, 2010, 04:29 AM
Authorized User
 
Join Date: Nov 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by HiTechCoach View Post
Did you ever get this working?
no not yet...
i want the 'phonenumCount' field to auto count the duplicated 'phoneNum' when i type the phone number....
like ... when i type '5553330' in 'phoneNum' field, the 'phoneNumCount' field shows that this number has been duplicated 4 times
and when i type '4300112' in 'phoneNum' field, the 'phoneNumCount' field shows that this number has been duplicated 3 times and so on

need help please

Last edited by DivX; November 11th, 2010 at 05:16 AM..
 
Old November 11th, 2010, 12:55 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

As Malcolm has pointed out, you normally do not store the count. It is calculated as needed.

If you want the count to show in a control on a form then you could set the control source of a text box to display the DCount() for the control that has the phone number.

For this I would expect to see multiple tables used.

When I have done this, after a phone number is select from the drop down list the customers information is displayed. Below that, in a sub form all the previous calls are displayed.

I suggest that you take a look at these free templates:

Customer Service

Issues
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old November 11th, 2010, 07:34 PM
Authorized User
 
Join Date: Nov 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thnx alllllllllll
i figured it out
Code:
Me.PhoneNumCount = DCount("phone_num", "PhoneProblems", "phone_num =" & [phone_num])
thnx for your help n support

cheers
 
Old November 11th, 2010, 10:47 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

You're welcome!

Thank you for the update. Glad to hear you have it working.
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015





Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple question? Cade_Feng BOOK: Beginning Regular Expressions 3 October 18th, 2012 07:14 PM
Question about counting records based on condition TheBlueSky Crystal Reports 1 May 31st, 2006 03:35 AM
Simple question maximus101 Classic ASP Basics 2 October 18th, 2005 10:22 PM
Simple Question dinosaur_uk VB.NET 2002/2003 Basics 1 September 10th, 2004 09:43 AM
Simple Question MSK888 C# 4 August 1st, 2004 12:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.