Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Form Checkbox

How can I detect when the user clicks the checkbox it the top corner of the form?

Technically speaking, I actually wish to intercept this and make the form invisible, and keep it running, rather than actually close the application.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Checkbox On Excel VBA Form
I have a form in Excel VBA that has approximately 30 checkboxes. I wanted to know if there was a way to use a For...Each statement to check each checkbox and return the checkbox value (whether it is true or false). I have tried this but have had no luck. If you know if this is possible or if there is a better way, please let me know.


How Do You Loop Through Every Checkbox In A Form?

I used this piece of code found searching the archive:

Dim ctl As Control
For Each ctl In Form1.Controls
If TypeOf ctl Is CheckBox Then

...But it never beeps! (The form does have checkboxes...)

In the thread where I found it, they report the problem but they didn't tried to solve it as there was a simpler solution...

Any idea??

How Can I Return A Checkbox To A Form
I am reading a drive for Dirs and files(done). But I need to have a checkbox appear with my result on the form for the user to select which file/dir they want to include in the final file.
1. = Is it possible to code a checkbox onto a form
2. = If so, I assume that using an array and counter to increment the check box values is the correct method.

If anyone can help with at least the code to put a check box on the form, I should be able to take it from there.


PS. I am relatively new to VB

I Have A Form With 24+ Checkbox Names, I Want Them In An Array, Help!
I have a form named purgedir with about 24 checkbox's. I want to pull the names into an array, i used the code below and it isnt working, please help.

dirAry is an empty array, it is not overflowing, i just cant pull the checkbox caption

For i = LBound(dirAry) To UBound(dirAry)
dirAry(i) = sRoot & purgedir.Controls("CheckBox" & CStr(i)).Caption
Next i

Using VB To 'click' A Checkbox In IE Browser Form

I am a bit stumped on this one. i have tried number of ways that work on other forms to get the checkbox on this web page to 'click' or 'check' etc

here is the macro

Sub test()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate ""
Do Until .ReadyState = 4
Do While .busy: DoEvents: Loop

Set fb1 = .document.forms(0).Item("em")
fb1.Value = "3"
Set fb2 = .document.forms(0).Item("ey")
fb2.Value = "2005"
Set fb4 = .document.forms(0).Item("version")
fb4.Value = ABC
fb4.Checked = True
End With
End Sub

and here is the salient portion of the html code:

<input type=CHECKBOX name=version value=ABC onclick="Selectversion(this.form,true)">T2<br> <input type=CHECKBOX name=version value=DEF onclick="Selectversion(this.form,true)">T3<br>

getelementbyId doesnt work either. and i tried .click, and several other various cominatins of .text, .value, etc etc, but cannot figure out how to get the desired checkbox to 'click'

any tips here would be appreciated



Checkbox Problem: Form To Module
is it possible to run code in a module, bring up a form for data (checkbox), and store that data to use later in the module?

Updating Checkbox In User Form
I'm a newbie so sorry if this question has been beaten to death.
I have a series of checkboxes on a user form. As a web query is progressing, I would like to show what it has done by making a checkbox value true. The only way I been able to make it happen is after the macro has completed.
Is there a way to make the checkbox 'checked' and show on the user form during the operation of the macro?


Changing Values For A Checkbox On An Excel Form

I'm using VB6 to populate an Excel file that I've created. The Excel file has a few controls on it, including some checkboxes. This is the code I'm using to populate the checkboxes:
Dim Index As Integer
Index = 1
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:WINDOWSSYSTEMSales Order Template.xlt")

obWorkBook.Worksheets(Index).chkCheque.Value = True

' Save as a temporary file to save the template and show the temp file
obWorkBook.SaveAs ("C: empsales.xls")
obExcelApp.Visible = True

' clear the variables
Set obWorkBook = Nothing
Set obExcelApp = Nothing
When the excel file opens though, the checkboxes don't visually appear to be checked. They are checked, however, if I messagebox their values. Also, once the form is open, the first time that I try to check (enable) them, they flash checked but remain unchecked. After that they work normally (going from checked to unchecked)....It's as if the form is not being refreshed when it first loads.

If you can help me out, it would be greatly appreciated.

Thanks a bunch,


Cant Think Of Title {access Checkbox On Other Unloaded Form}
I want a checkbox on a form which is not loaded to be involved in the code of another form. How can I do that? I'm using VB6.

Need To Capture Which Checkbox Is Checked And Pass The Value To Another Form...
Hi, i hav a problem dat i need help wif.I hav a group of checkboxes dat the user can choose and i need 2 capture which they clicked.Thing is the checkboxes r on a different form & i wil be needing the values on another form...can any1 advise me on how do i go abt doin dat??

Access A Checkbox On A Form Of Another Program Which Is Running
Does anyone know VB6 can change a checkbox value on a form of another program which has been running.

Checkbox Holding Textbox Data (Word Form)
I am creating a data entry form for a word document with an "add" function. The add function will allow a new line to be created using the existing data entry fields but, I want to clear all textboxes on repeat except any with selected checkboxes.

This is the code for the "add" button...

Private Sub CommandButton1_Click()

Dim strString As String
Static ID As Long

ID = ID + 1

strString = strString & ID & Chr(9) & TextBox1 & Chr(9) & TextBox2 & Chr(9) & TextBox3 & Chr(9) & TextBox4 & Chr(9) & TextBox5 & Chr(9) & TextBox6 & Chr(9)

ListBox1.AddItem strString

Selection.MoveRight Unit:=wdCell
Selection.Text = ID

' the following textboxes need to be cleared or the current data held depending on the checkbox

Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox1
Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox2
Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox3
Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox4
Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox5
Selection.MoveRight Unit:=wdCell
Selection.Text = TextBox6

End Sub

Anybody have any ideas?

VBA/Access: Checking Checkbox On Record Change In Form
Hi all,

I hope this is in the right place, if not, I do apologise:

I have a form, which contains a checkbox, when the checkbox is ticked, a texbox appears, when it is unchecked, the textbox disappears. Problem is: When I load the form up, if the checkbox is ticked, the texbox doesn't appear (since the event procedure is only activated when I click on the object.)

I need the checkbox status to be checked EVERY time a record is changed so that depending on whether a record has a tick in the box it will either show or hide the text box. This can differ between records so I need to check every record.

Is there a quick way of doing this without opening a database connection, then creating a object for the recordset and doing it from there?

Thank in advance for any tips/tactics.


Disabling Visual Basic Checkbox Of Form In Access
Hell I'm a beginner programmer and I need help with writing code to disable one checkbox when another one is selected.

Please Help Me

Thank You

Turning A Checkbox Laden Form Into A Text Template In VB
So im creating a form in VB that utilizes check boxes and exports the checked checkboxes into a specifically formated text document.
i simply do not know how to export all check boxes out of vb and into word or wordpad or something similar.
pic is included.
Thank You

Display Checkbox Value From MS Access To A Textbox In Visual Basic 6 Form
hello everybody,
im new here...
i wanted to ask this: how do i display checkbox value from my database MS access to a textbox in a visual basic 6 form? it has been displayed "True" or "False" but i want it to display "Active" for true value and "Not Active" for false value.
i want to send value from my option buttons, optionActive and optionNotActive. if optionActive is true, then the value sent to ms access is also true (where it checks my checkbox) and vice versa.
im sorry if the questios are not clear enough. if there's any doubt regarding my questions, feel free to ask me back. :)
thank you very much for assisting me.

Outlook Form: Click On CheckBox And Auto Add E-mail To BCC In Message Area

I am very new to VB. As in just looked at a basic explanation a few hours ago. Kind of lost. I'm computer literate but this is all new to me. I'm hoping someone can help me out and it would be much appreciated.

I'm setting up a one off Outlook Form with a few basic functions. Most of it is simple textboxes and checkboxes.

For 3 checkboxes on page 2 if 1,2,or 3 of them are checked, I wanted it to automatically add a particular e-mail address to the BCC, recipientcontrol1, in the Message section on Pg 1. And if someone made a mistake in checking 1 and they unchecked it then that e-mail address would disappear. It's for various people to use so wanted to automate some things. Is this possible?

Thank You.

Getsetting Checkbox Dont Work With Many Checkbox

I hope somone can help me please with this

I am tray to use this code to hide and show Row in Listview
I can hide Row and show agen
but I can not use savesetting and get setting to remember status of checkbox?

when I save settings then I can see in regedit I save settings
but when I use getsettings ewritging go back to Value = 1

but I can save 1 checkbox then put X back in checkbox and change another then I
can save 1 check box in the time not 2 3 or more ????

I use getsetings in for load
and savesetings then I klick on the checkbox

Call hideIDsub

Public Sub hideIDsub()
If form.hideID.Value = Checked Then
form.ListView1.ColumnHeaders(1).Width = 400
form.ListView1.ColumnHeaders(1).Width = 0
End If
End Sub
Public Sub hidenamesub()
If form.Hidename.Value = Checked Then
form.ListView1.ColumnHeaders(2).Width = 2500
form.ListView1.ColumnHeaders(2).Width = 0
End If
End Sub

Public Sub Hidehomesub()
If form.hidehome.Value = Checked Then
form.ListView1.ColumnHeaders(3).Width = 1200
form.ListView1.ColumnHeaders(3).Width = 0
End If
End Sub

Public Sub savesetings()
SaveSetting "app", "Grid", "id", form.hideID.Value
SaveSetting "app", "Grid", "name", form.hidename.Value
SaveSetting "app", "Grid", "home", form.hidehome.Value

End Sub

Public Sub getsetings()
On Error Resume Next
form.hideID.Value = GetSetting("app", "Grid", "id", "")
form.hidename.Value = GetSetting("app", "Grid", "name", "")
form.hidehome.Value = GetSetting("app", "Grid", "home", "")

End Sub

Noob Q:tell/set A Checkbox Value (checkbox Stlye Listbox)
sorry bout this but how do u tell if a checkbox has been ticked (and set it), that is the checkboxes in a listbox with checkbox style on.

ive tried .itemdata there isnt a .value item i can find so where do i look?
i know about the itemchex event but i need to change which have been clicked

im sure theres a better way to phrase that but that what i came up with

Checkbox = True For Only 1 Checkbox In A Group
With the older versions of Word, I used to be able to put a couple of check boxes (Very Good, Good, Poor) in a group after a question and make it that only one of the boxes could be true for each question in a survey. Now in word 2002 I tried to do it and can't seem to find the group option. I have been away from this type of work for a long time and wonder if it can only be done via code now?

If you can point me in the right direction, I would appreciate it.


CheckBox In Access To CheckBox In Word
I have check boxes set up in Access and I have corresponding check boxes setup in Word. I am using the following to get the text boxes to transfer to Word:

Set MyObject = GetObject("c:access testP742001-01.doc")
MyObject.Application.Visible = True
If Me![TITLE] <> "" Then MyObject.Bookmarks("Text1").range.Text = Me![TITLE]
How do I do the same for the check boxes. I have tried to search this out. Trial and Error has not proven successful either.


Displaying A Checkbox In Access As A Checkbox In Vb
The checkbox in access is called Completed. i am trying to populate a datagrid based on a SQL statement in VB, including this checkbox, but in the grid, it is only being displayed like a text field - is there anything i can do about this? here is my code for it - any help would be appreciated!

Dim checkSQL As String
    checkSQL = "SELECT OrderGenerate.OrderNumber, Client.Company, OrderGenerate.Completed " & _
                " FROM Client INNER JOIN OrderGenerate ON Client.ClientCode = OrderGenerate.ClientCode " & _
                " WHERE (((OrderGenerate.OrderDate)=" & dToday & "))"
    Set RS = Conn.Execute(checkSQL)
    Adodc1.RecordSource = checkSQL
    DataGrid1.Visible = True
    Set DataGrid1.DataSource = Adodc1

Color Checkbox 'checkbox'
HowcouldI affect the color of the option and checkbox control, like I can do fore/backcolor, but I want to also affect the check box color, or the option donut hole color. I have some dark interfaces, and those controls glare like flashlights, and I want to try to color them like the other controls, in a way. Any idea how to color a checkbox 'checkbox'?

Listbox+Checkbox: Clicking Text = Clicking Checkbox
Hello all. This seems like such a simple question to me that I was sure it had already been asked. But I did a search and couldn't find anything. So there's no need to flame me if this is redundant.

I have a listbox with style set to use checkboxes. From the user's perspective, clicking on the text of a line in the listbox should be the same as clicking on the checkbox of that same line. Additionally, I have no need for the user to see any lines of the listbox as being highlighted, so I am resetting .listIndex = -1. Here's what I've been trying:

VB Code:
Private Sub listSpecialOptions_Click()'Clicking on the text of a listItem is the equivalent of clicking on that item's checkbox.'Also, Return listIndex to -1 so that no line is ever highlighted.  Only the checkbox status should be displayed.'Static variable ClickedOnText is used to prevent an infinite loop of toggling checkbox when user clicks on the text of a listItem.Static ClickedOnText As BooleanWith listSpecialOptions   If (.ListIndex <> -1) And (ClickedOnText = False) Then      ClickedOnText = True      .Selected(.ListIndex) = Not (.Selected(.ListIndex))   End If   .ListIndex = -1   If (.ListIndex = -1) And (ClickedOnText = True) Then ClickedOnText = FalseEnd WithEnd Sub

I am no longer getting infinite loops. However, now clicking on the checkbox has no visual effect -- the checkbox is changed, and then changed again because the .listIndex is highlight. Effectively, it's processing not(not(.selected(.listindex))).

So my question is this: Is there a way to differentiate between the user clicking on the checkbox and the user clicking on the text? Thanks all for your help!

For Each Checkbox
hi everyone,

I have a form with lots of checkboxes, and i add some checkboxes dynamically. Now I want every checkbox unchecked.

I thought about something as:

for each checkbox in me
checkbox.value = 0

but I doesn't work and there aren't many examples, even more...
this forums' search function can't find words like "each", "for", "for each", ... to common

anyone suggestions?


Help me please! I am stuck on using checkboxes, as I have never used them before. I am making a page on excel where it is a list of items (for selecting like an internet shop). I want to know how to make it so that when you select the checkbox when moving to the checkout page it comes up with the ones that were selected. Anybody got an old project that they can cut n paste it from?

CheckBox Help

Can someone tell me what I'm doing wrong in the following VB code. My code is trying to achieve this in an Excel form:
When the user ticks the Check Box the macro should enter value "5" in cell K3. Similarly if the user unticks the same check box it should revert to having no value in it. I get runtime error '424' when I try to run it. Please help!
P.S. I'm an absolute novice so be a bit desriptive please.

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
With Sheets("Sheet1")
.Cells(3, 11).Value = "5"
End With
CheckBox1.Value = False
With Sheets("Sheet1")
.Cells(3, 11).Value = ""
End With
End If
End Sub

whew! guys, i hope you could help me with this.

we're asked to do a simple calculator, with just the 4 basic operations. (add,subtract,multiply,divide)

but the problem was to add a checkbox which when checked will display a messagebox containing the 1st and 2nd integer being inputed and the answer. if it is unchecked, then the answer wil be displayed only on the label.


6 + 6 is equals to 12

>>>this is my code. it's not yet complete. i don't know what to add now. how can i let the value inputed, the message and the answer appear in the textbox? what code to use? please help me. thanks!

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Label1.Caption = "1st integer"
Label2.Caption = "2nd integer"
Label3.Caption = "Answer"
Label4.Caption = ""
Check1.Caption = "use message box"
Option1.Caption = "+"
Option2.Caption = "-"
Option3.Caption = "*"
Option4.Caption = "/"
End Sub

Private Sub Option1_Click()
Label4.Caption = Val(Text1.Text) + Val(Text2.Text)
End Sub

Private Sub Option2_Click()
Label4.Caption = Val(Text1.Text) - Val(Text2.Text)
End Sub

Private Sub Option3_Click()
Label4.Caption = Val(Text1.Text) * Val(Text2.Text)
End Sub

Private Sub Option4_Click()
Label4.Caption = Val(Text1.Text) / Val(Text2.Text)
End Sub

a text box can be made transparent. There is no way i can see to make a checkbox text transparent, or am i wrong???????.

Checkbox Help
Hi Guys! I need some help with my program. I'm building a motion
extraction program. Basically, what it does is to extract certain
marker/s from a master motion capture file and save it into a much smaller new file. It works by using exel object. Running a simple copy & paste actions
from the master file onto a template file. I manage to make exel work
smoothly for most of the task exept one. On the form I use
checkbox so that the users can choose which marker/s they need. My problem is, how do I make the program count the number of marker/s checked by the user and the put it onto a specific cell. For example say if the user checks 3 markers, means I need to put the number 3 on to Range("D3") in the template file. I attach the form to give you guys a better picture. Am I making any sense? help me
please ....

a mate of mine is working on prog in excell
and he is using about 50 checkboxes in it
has 2 pages in worksheet
in sheet 1 has 60 checkboxes
which when checked copy data to sheet 2
is there an easier way

I have a checkbox in my form. How can I represent its value in access?
I mean how can I represent it in access such that if I open my database I know whether it has been checked or not.

i have a listbox set to be a checkbox.

after the user selects the items to print, i want to uncheck the checked items. at this time i simply reload the checkbox and this causes the checkbox to go blank for a second while it reloads.

can i reset the selected items without reloading??


i wanna click a button or whatever and if the check box is checked open another thing, if not open some other thing. i wrote this:

If check1.??? then form1.hide

I wanna know what to put in the ??? marks?
thankz in advance


DAO With A Checkbox
i would like to know how i can get the value from my table in access and put it into a checkbox.

the table is called "usernames" and the field is called "admin" it has a checkbox in it"

i tried the following code to get the contents of this field and put it into my checkbox which is called "chkUserSecurity"

chkUserSecurity.DataField = rs("Admin")
chkUserSecurity.Value = rs("Admin")

"rs is the recordset and i have already made the databse connection by using the following code

Set DB = OpenDatabase(App.Path & "FSDatabase.mdb", False, False, ";pwd=" & Password)
Set rs = DB.OpenRecordset("Usernames")

can someone please help me, ps i am NOT using the data control!

thank you

Hi! I am having some problems with the checkbox. How do can I read the value of the checkbox? I tried the following example, but it does't seem to work. Please Help!

if check1.value = true then ...

Was it possible to create a group of checkbox that act like radio bouton. i wanna have only one checked at the same time.

excuse my english, thank

merry christmas !!!!

New The Checkbox
How can I new a Checkbox when it load the form?

I want to use some checkboxes in a form.
Do I need to define this value as Yes/No fields in my Access database ?
or can it works against text-fields in Access ?

I have two checkboxes when I click the first the other should be unchecked.

Private Sub cb1_Click()
cb2.Value = 0
End Sub

Private Sub cb2_Click()
cb1.Value = 0
End Sub

But when you click on the checkbox the other checkbox value will become 0 but the checkbox you click will not be checked? Why is that?
What can I do to make it work? I would like them to work as radiobuttons. (I can't use radiobuttons because in some cases both checkbox values will be 1)

checkn.value is to be 0-unchecked or 1-checked.

if I write these values to an Access db, values are noted as 0 or -1.
retrieving these values as datan.recordset.whatever results in an 'invalid use of property' as the value is negative.

how to avoid this ???

Checkbox In Vb
hi friends,

Thanks in advace for your help..

i have obne checkbox in my from,,

after i sellect(chechked) checkbox i make some boolean values true the i use that one around the project....

but the probelm,,

after close the checkbox form and close the application , i jsut the check the checkbox it is unchecked..

which means everytime i run the application i need to check again....
so i need once i select(check) the checkbox , this oen always checked until i myself unchecked ...should not change one form's closed or application...

here are my code::

If hwcheck.Value = 1 Then
hardwarecheck = True
End If

how to do this one???

can give me ur valuable information ....

do i need to anyhting in the form_Load event??

waiting for your reply...

with regards,

Checkbox Help
How do i save the value of some checkboxes to a text file

i have 5 checkboxes, when i click save i want to be able to save the status (vbcheckedvbunchecked).

then i want to be able to load them again.

CheckBox Help.
I have some code and it wont change whenever i check the box.

VB Code:
private sub timer1_timer()If Check1.Value = True Then    If Text1.Text = "a/k" Then        Text2.Text = "21.73%"        Text3.Text = 9.52        Text4.Text = "1.66%"    End If    End If    If Text1.Text = "a/k" Then        Text2.Text = "18.29%"        Text3.Text = 9.41        Text4.Text = "4.83%"    End If   end sub private sub form_load()timer1.enabled = truetimer1.interval = 1end sub

CheckBox Help
Hi guys ive created a check boxes, is there any way of showing the results without using different string. or how would some else do a checkbox? would you do the same as me. have different strings for different checkboxes? if so how?

Thanks Alot

VB Code:
Dim cx1 As StringDim cx2 As StringDim cx3 As StringDim cx4 As StringDim cx5 As String  If c1 = True Then cx1 = "Swimming"If c2 = True Then cx2 = "Jacuzzi"If c3 = True Then cx3 = "Sauna"If c4 = True Then cx4 = "Boxing Toning"If c5 = True Then cx5 = "Tanning"

For Each (Checkbox)
Hi everybody !

I tried to search before to post but It's not possible to search these two words (For, Each)...

I have some checkboxes with control Array(index 0 to 80) on my form and I want to uncheck only the checkboxes with index 0 to 40, how can I do this with the For Each function ???

Thanks in advance !

I am giving users the option to disable pop-ups in a VB6 application which uses the WebBrowser control. I am using a CheckBox to implement this i.e. if the CheckBox is checked, pop-ups are disabled else pop-ups are enabled. By default, the CheckBox is checked. Please note that more than 1 instance of the browser can be opened simultaneously.

When the browser loads, the CheckBox to disable pop-ups is checked. Next I uncheck it & navigate to a URL. I open one of the links in a new window/instance of the browser. Under such circumstances, the CheckBox in the new browser window should be unchecked since the CheckBox in the window from which the new window has been opened is unchecked but the CheckBox in the new window remains checked. This is because by default, the CheckBox is checked.

Now how do I ensure that when the CheckBox is unchecked in the 1st instance of the browser, the CheckBox in any subsequent instances should be unchecked? Or in other words, how do I ensure that the state of the CheckBox is maintained when any new instances of the browser is opened?

One of the ways in which this can be done is by storing the state of the CheckBox in a text file & whenever new instances of the browser are opened, read that text file & check/uncheck the CheckBox accordingly but I did like to know if this can be done in some other way or not.



Checkbox Value
hi i was wondering if someone can tell me how to do the following

i have 9 checkboxes on a userform and a command button with a label and timer the label caption goes from 1 to 17, what i need to do is this when the command button is clicked and the caption is (lets say) 1 i need check box 1 to be checked (this i can do so far). when the command button is clicked again and the lable caption is again 1 i need the check box to uncheck. here is the code i have sofar.

VB Code:
Private Sub Command1_Click()If label1.Caption = 1 Then    Check1.Value = 1ElseIf Check1.Value = 1 & label1.caption = 1 Then        Check1.Value = 0End IfEnd IfEnd Sub

somehow this doesnot work it will check the checkbox but not uncheck it when i hit the button for a second time.

can someone help me please cause im stuck and need the help thankyou.

i need to put a checkbox to a dbgrid to make partial selection of items show on the grid, can any one help

Copyright 2005-08, All rights reserved