Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6846333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:36:31+00:00 2026-05-27T00:36:31+00:00

Basically Im a vba programmer and Iam facing a serious problem with the checkbox

  • 0

Basically Im a vba programmer and Iam facing a serious problem with the checkbox controls of the VBA.I have to select and deselect the checkboxes as per user selection. I believe this is a general question for vb.net also.

some sample code

 sub chk3_Click()

  if userform.chk3.value = true then
     userform.chk4.value = true
     userform.chk2.value = true
  end if

 end sub

 sub chk4_click()

  if userform.chk4.value = true then
     userform.chk3.value=true
     userform.chk1.value=true 
  end if

 end sub    

This is the sample code, I have to turn on the other checkboxes based on user selection of the checkboxes.but the problem Im facing is when it executes the statement

userform.chk4.value = true in the sub chk3_click 

it is invoking the sub chk4_click sub and again finding the

userform.chk3.value=true in sub chk4_click(), invoking the sub chk3_click 

I am unable to understand how to solve it .

I have tried with various events mousedown, mouseup and change in value also after update but none worked.These events are crashing the tool I dont understand why but they are crashing so I just ignored to use those events.

Finally I have used a flag which is defined globally in the workbook and using the if condition I have did it but its looking to bad style of coding. Could anyone help me with these ?

This is what I have done to resolve the problem . It works but I dont think its good style of programming.

 dim i as integer

sub ch3_click()

  if i = 0 then
     i = 1
     if userform.chk3.value=true then
        userform.chk4.value =true
        userform.chk2.value=true
     end if
     i = 0
  end if

end sub

sub chk4_click

  if i = 0 then
     i = 1
   if userform.chk4.value = true then
      userform.chk3.value=true
      userform.chk1.value=true
   end if
     i = 0
  end if

end sub

Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:36:32+00:00Added an answer on May 27, 2026 at 12:36 am

    That is actually a very valid way to approach the problem, you just need to have a more descriptive name and type for i, such as

    Dim InClickEvent As Boolean
    

    Then change your click event code to something like:

      if Not InClickEvent then
         InClickEvent = True
         if userform.chk3.value=true then
            userform.chk4.value =true
            userform.chk2.value=true
         end if
         InClickEvent = False
      end if
    

    Even better is if your version of VBA supports Try/Finally, which I believe it does, you can make sure the flag is always cleared even if you have errors with the following version of the code:

      if Not InClickEvent then
         Try
            InClickEvent = True
            if userform.chk3.value=true then
               userform.chk4.value =true
               userform.chk2.value=true
            end if
         Finally
            InClickEvent = False
         End Try
      end if
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have two models: User and Godfather. The godfather table has three columns:
I've got some VB code (actually VBA) which is basically the same except for
Basically I have some code to check a specific directory to see if an
I have a bunch of VBA code that I'd like to throw in a
I have VBA code in an Excel spreadsheet. It is used to set the
I have not had much experience with VBA, but I sometimes use it at
I have a VBA publishing macro in Excel which generates a published workbook based
Is there some limit to what I can select in a range via VBA?
I have written a little Excel VBA report tool for my iPhone App sales.
I have requirements from our client where we basically have to 'parse' PDF files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.