Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 March 25th, 2005, 08:52 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Counting Checkboxes On A Continuous Subform

I've read through a number of discussions in different forums on this topic, but there's something that I'm not getting to make my project work. So I'm including a link to illustrate my problem. My goal is to count only those checkboxes that appear on the form to get the "total checkboxes" and count only those checkboxes that are checked (selected) on the form to get the "selected checkboxes count". This is because the next part of my project's development involves cycling through all shown selected records to send email, but I'm not there yet. The emphasis is to count what is on the form only, because what shows up on the form and what remains in the table are different.

If someone can tell me of another way, I'm open to suggestions. The queries and filters that I've used with a date range somehow give this difference between selected checkboxes on the form verses on the recordsource table.

Right now my design counts directly from the recordsource, which gives me an incorrect count. See linked sample to examine what I have so far and let me know if what I'm asking can be done. The problem comes when I add a date range and the count doesn't change. I've created a code that I think more closely takes information directly off of the form, but I still need someone's help. The Public Function CheckboxOnForm() give me an error. Download the file from http://www.utteraccess.com/forums/do...?Number=668080


Thanks,
PC
 
Old March 26th, 2005, 07:01 PM
Authorized User
 
Join Date: Mar 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Were ever you need that information, you collect it easily by sending a SQL string with the condition.
For example:
In a subform, you set the RecordSource property to the condition you need and you get only the records that meet that same condition.

If your problem is how to work the string in VBA, that then is more specific.
If that is the case, let me know.

I could not see your linked sample for it asked me to sign in to something

 
Old March 27th, 2005, 03:33 AM
Authorized User
 
Join Date: Mar 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I saw your project.

Two questions.

Do you need the autoNumber field?
Because if you don't, remove it right away.

[quote]Right now my design counts directly from the recordsource, which gives me an incorrect count.[\quote]

Were is the count incorrect?

1 correction
RecordSource is a property of the Form and Report objects.
You can use the RecordSource property of the subform to specify the source and criteria of data for your needs.
What your doing now, which is also fine, is:
you are specifying in the Control Source property of a text box a simple count with a condition.
But it also ends there.

1 Idea
What I think you need now is to use the RecordSource property of the subForm with more creativeness.



 
Old March 28th, 2005, 05:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

To count the number of checkboxes that are ticked in a form:


Dim ctlControl as Control, bytCount as Byte

bytCount = 0
For Each ctlControl in Me
    If ctlControl.ControlType = acCheckBox Then
        bytCount = bytCount + Abs(ctlControl)
    End If
Next ctlControl


This works because a checkbox is either true (-1) or false (zero). So all the true ones will increase the counter by one.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old April 26th, 2005, 09:26 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help. For others interested in this solution, I'm posting the working sample that I've developed. I'm providing a link, because I don't see a way to upload the file to this forum.
http://www.utteraccess.com/forums/sh...0958&bodyprev=

PC





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replicate 'group by' in continuous subform? PeregrinTook Access VBA 0 May 3rd, 2007 04:11 PM
Change button caption on continuous subform PeregrinTook Access VBA 2 April 16th, 2007 05:16 PM
Checkboxes and continuous forms mdProgrammer Access VBA 4 August 3rd, 2006 09:47 AM
Filter Subform B Based on Field in Subform A SerranoG Access VBA 3 June 18th, 2004 12:23 AM





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