473,406 Members | 2,371 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,406 software developers and data experts.

Working with Check boxes

Hi I am working with checkboxes and counters. Each time I click a checkbox I am adding one to a count (displayed in a text box). The counter works for the first record, however when I am on the next record in the dataset, it count is not displayed in the text box. Not sure why this is happening. See code below.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Check769_Click()
  2.     'Dim count1 As Integer
  3.  
  4. If Me.Check769.Value = "-1" Then
  5.      Reason1 = "Diagnosis not Included in CPOE."
  6.      Count1 = Count1 + 1
  7.      'MsgBox "I have added the count"
  8.  
  9. Else
  10.      If Me.Check769.Value <> "-1" Then
  11.         Reason1 = " "
  12.      End If
  13. End If
  14. End Sub
  15.  
Nov 10 '14 #1
5 1383
twinnyfo
3,653 Expert Mod 2GB
Each time you move to a new record your counter is cleared. You should declare a Class-specific variable (in the top of your VBA code, before any other subs.

However, I still think there are some logical problems with your form and the code.

First, there is no need to use the ".Value" property of your check box, as that is the default property. Second, the check box returns a Boolean value, not a Text value (as you have indicated with the "-1". A more efficient way to achieve the same thing is:

Expand|Select|Wrap|Line Numbers
  1. If Me.Check769 Then
  2.     Reason1 = "Diagnosis not Included in CPOE."
  3.     Count1 = Count1 + 1
  4.     'MsgBox "I have added the count"
  5. Else
  6.     Reason1 = " "
  7. End If
Notice the removal of the second If...Then.

Are you just counting how many times you lick the check box or are you counting records that have the box checked? This is not clear from your discussion or code.
Nov 12 '14 #2
I am counting how many times I click the check box.
Nov 17 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Have you tried using the class specific variable? What results did it provide?
Nov 19 '14 #4
I added the variables. Now I'm getting this error whenever I click on the checkbox and the database module.
"Member already exist in an object module from which this object module derives"
See code below:

Expand|Select|Wrap|Line Numbers
  1. Dim Count1 As Integer
  2. Dim Count2 As Integer
  3. Dim Count3 As Integer
  4. Dim Count4 As Integer
  5. Dim Count5 As Integer
  6. Dim Icd9_Code1_cnt As Integer
  7. Dim ICD9_Code2_Cnt As Integer
  8. Dim ICD9_Code3_Cnt As Integer
  9. Dim DX_Count As Integer
  10. Dim Qual_incent_cnt As Integer
  11. Dim Response_cnt As integoer
  12. Dim dx1_in_note_cnt As Integer
  13. Dim dx2_in_note_cnt As Integer
  14. Dim dx3_in_note_cnt As Integer
  15. Dim Note_Count As Integer
  16.  
  17.  
  18.  
  19. Private Sub Check769_Click()
  20.     'Dim count1 As Integer
  21.  
  22. If Me.Check769.Value = -1 Then
  23.      Reason1 = "Diagnosis not Included in CPOE."
  24.      Count1 = Count1 + 1
  25.      'MsgBox "I have added the count"
  26.  
  27. Else
  28.      Reason1 = " "
  29. End If
  30. End Sub
Thanks for your help!!
Nov 19 '14 #5
twinnyfo
3,653 Expert Mod 2GB
Sherian,

Your Dim Statements should be within the confines of the Sub itself. This is causing the error.
Nov 24 '14 #6

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

Similar topics

17
by: Dave Smithz | last post by:
Hi there, A PHP application I built has a section which lists a number of members to a club whose names each appear with a check box beside them that can be ticked. These check boxes are part...
2
by: Shabam | last post by:
I was told that dotnet generates classes for input tags like this: <span class="hello"><input type= "checkbox"></span> The problem here is, the "input" class is overriding the "hello" class....
0
by: mscir | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <x46dnXQO6_TFqErfRVn-jw@pghconnect.com> Lines: 24 NNTP-Posting-Host: 67.136.138.220 X-Trace:...
0
by: Robert | last post by:
Stephen, I think I figured out the problem. I was able to get Check Boxes and Option Buttons to work on my form by TURNING OFF RECORD SELECTORS on the form. Not sure why this would make a...
2
by: anget24 | last post by:
I am working on a form in access and I want my check boxes to move with the next question and eveytime i answer the question and move to the next question my check box stays checked and all I want it...
4
by: wish | last post by:
Dear all; I have a lot of check boxes in the page..if the the user keep check the check boxes rather then check one check box for all check boxes will checked.. May i have ur help to refer?...
3
by: Search & You Will Find | last post by:
I have a database in Access 2000 that I need some help on. I have three tables: PROJECTS, SYSTEMS, & SYSTEMSREF. They possess the following fields: -----------------------------------...
15
by: martin DH | last post by:
Good morning, I have added several posts out here on a project on which I am working - thank you very much to everyone who has responded with ideas and solutions! My new question: I am drawing...
1
Fspinelli
by: Fspinelli | last post by:
Hi, I have to run a query based on check boxes that are checked. Only those records with a specific check box (or boxes) should come up. I created a form off of that query using those check...
3
Fspinelli
by: Fspinelli | last post by:
I have a table with various information (company name, address, etc.) plus five check boxes. One or more of those check boxes may be ticked as it relays a type of status to the end user. I have a...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.