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





See Related Forum Messages: Follow the Links Below to View Complete Thread

ListView: When A Checkbox Is Checked...
I want to run a function every time a check box is checked in my listview box. Is there any way to specify like, an OnCheck event? I know there isn't onCheck, but it would be nice, rather than looping through everything... well, as you can guess I'm a newb with this

To explain further: There's a ton of items in this listview. Whenever an item is checked, I want its text to appear in a textbox below, so as to keep a running list of what the user has checked rather than having to scroll up and down...

If anyone can tell me or point me to a property name or something that would be great

Listview Checkbox Checked Listitem
hi,please help .how edit the sQL statement, if use the listview checkbox to insert data from listview checked listitem into Temp Table.

this is the current code:

Code:
For Each lstsel In ListView1.ListItems
strSQL = "Insert Into Temp (EmployeeName, EmployeeNo,Designation,Department,Shift,OvertimeDate,TimeFrom,TimeTo,Breaktime,OtRate,CategoryDay,WorkDescript,WorkDetail,othours) Values (" & _
"'" & lstsel.Text & "', " & _
"'" & lstsel.SubItems(1) & "', " & _
"'" & lstsel.SubItems(2) & "', " & _
"'" & lstsel.SubItems(3) & "', " & _
"'" & lstsel.SubItems(4) & "', " & _
IIf(lstsel.SubItems(5) <> "", "#" & Format(lstsel.SubItems(5), "dd-MMM-YYYY") & "#,", "null,") & _
IIf(lstsel.SubItems(6) <> "", "#" & lstsel.SubItems(6) & "#,", "null,") & _
IIf(lstsel.SubItems(7) <> "", "#" & lstsel.SubItems(7) & "#,", "null,") & _
IIf(lstsel.SubItems(8) <> "", "#" & lstsel.SubItems(8) & "#,", "null,") & _
"'" & lstsel.SubItems(9) & "'," & _
"'" & lstsel.SubItems(10) & "'," & _
"'" & lstsel.SubItems(11) & "'," & _
"'" & lstsel.SubItems(12) & "'," & _
"'" & lstsel.SubItems(13) & "')"

Debug.Print strSQL ' Check the value in the immediate window
conDataConnection.Execute strSQL
Next
Set conDataConnection = Nothing


thanks for help!

How To Detect A Listview.checkbox Is Checked ?
Hi,

I need to perform some calculation and display the result on screen when everytime the user clicked a checkbox within a listview ? The user can click more than one item ?

e.g. txtGrandTotal = txtGrandTotal + ListView1.Selected.Subitem(3)

Checked/Unchecked Listbox Array
Hi guys i have a control array of 7 list boxes i want to fill 2 strings based on which of these are checked.

I.e if none of the list boxes are checked then when i check it fill Str1 with the check boxes text.
but if one of the 7 check boxes is already checked then fill Str2 with the check boxes text.

if it helps the reason for this is for an Sql query obviously i don't want to keep modifying the query each time i want a different search combination. i just want to define the strings and populate them base on the list box selections made.
Oh there will be multiple items in some of the list boxes but only ever one selected in each box and a maximum of 2 list boxes selected at any one time.

thanks in advance

Listview Checkbox Checked Display At Textbox
hi,please help.how to display the listview checkbox checked item display at textbox???

for example:
At listview when the selected checkbox is checked value 0.001 at textbox will display 0.001.

thanks for help!

Listview Checkbox Checked Display At Textbox
hi,please help.how to display the listview checkbox checked item display at textbox???

for example:
At listview when the selected checkbox is checked value 0.001 at textbox will display 0.001.

this is my current code
Code:Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Dim dimension As String

dimension = Text1.Text

   dimension = Item.Text
  
End Sub
 

thanks for help!



Edited by - monchichi on 11/23/2007 6:49:37 PM

Displaying A Listbox Item As Checked Or Unchecked
In the code below I want to display the checkbox as checked or unchecked depending on a value in the recordset. I haven't been able to find how to do this. I've tried
"lstRtnMthProfile.Selected (1)" to check them but that throws an error.


CODE Do While Not rsMethodProfiles.EOF
        lstRtnMthProfile.Font = "Times New Roman"
        lstRtnMthProfile.FontBold = True
        lstRtnMthProfile.FontSize = 12
        lstRtnMthProfile.AddItem rsMethodProfiles.Fields("MethodDesc")
        If (IsNull(rsMethodProfiles("ruleID"))) Then
           lstRtnMthProfile.Selected (0) 'uncheck the box
        Else
           lstRtnMthProfile.Selected (1) 'Check the box
        End If
        rsMethodProfiles.MoveNext
   Loop

CheckBox Becoming Unchecked
See picture.
[IMG]Pic.jpg[/IMG] <- How do I put a picture here?
In my program, a user may click a checkbox. When the checkbox is checked and the user clicks "description", the field is entered as shown. Then you click OK.
When you come back into the program, the checkbox is unchecked and the diameter symbol is before the parenthesee. So if a user were to check it again and click description (updating the info), the symbol would be there twice.
How can this checkbox be kept checked?
Thanks!

Adding A Listviewitem That Has Been Checked To Another Listview As It Is Checked
I have two listview boxs... I need help in finding out how to move an item from lvMain as it is checked to lvTentative. Can I do this dynamically or will I have to add a command button to walk through the list to check for the status of each item? If I can move the item as it's checked, can you point me in the right direction for the coding of this?

Thanks for any help
Shugt

Saving The State Of A Checked Menu Item
I have a menu item called mnuOptionsRunAtStartup. Of course, its purpose is to make the program run at startup. When I click the item, it shows as checked, puts the value in the correct place in the registry, and everything. However, when I restart my system, my program doesn't run automatically. I checked the registry entry, it was there. Then I checked the menu item, and found that it was unchecked again. I searched the forums, and came across a command called SaveSettings or something like that, but the messages didn't have exactly what I was looking for. I tried this snippet, but got no results:

Private Sub cmdExit_Click()
SaveSettings "WinHelper", "frmMain", "mnuOptionsRunAtStartup"
End Sub

This seems to be the only thing that would make sense. What am I doing wrong?

Listview Remove Item When Unchecked
Hi,

Ho do I remove an item from the listview when I gets unchecked? I can't use the SelectedItem, 'cause that isn't always the case. Just the Checked=False.

Thanks for the reply in advance.

If No Checkbox Checked
sorry if this is a stupid question but how can I get an error message to show if someone omits to check any checkbox in a form.Thanks any help you can give.

Determine Which Checkbox Is Checked
Hello!

I have a problem again. I have 4 checkboxes. Any of them or all of them can be checked.

How would I determine easy way which checkbox is checked. For example if Checkbox1 and Checkbox3 is checked, it takes the caption of these 2 checkboxes and puts to another label (leaves out the caption of Checkbox 2 and 4). Now I have following code:

If Checkbox1.Value = True And Checkbox2.Value = False And Checkbox3.Value = False And Checkbox4.Value = False Then Label.Caption = Checkbox1.Caption

ElseIf Checkbox1.Value = False And Checkbox2.Value = True And Checkbox3.Value = False And Checkbox4.Value = False Then Label.Caption = Checkbox2.Caption

and so on...

With 4 checkboxes I have over 8 different if conditions, because eighter first checkbox can be checked, second checkbox, first and fourth checkbox etc.

How could it be done reasonably?

Laura

CheckBox Won't Stayed Checked
I'm stumped. After MSDN, this forum, and coworkers, I still can't figure this out. This is what we're trying to do:
If this checkbox is checked, write this symbol to a textbox field AND store a certain value (0 or 1) as a File -> Property so that when we run this program in the document again, the checkbox will know if it was checked before.
Make sense?
The code is really long, so it's attached. Do a search for VBHELP and there's two areas to look at.
If anyone knows how to fix this, or maybe has time to check this out, I'd really appreciate your advice. This is so frustrating.
Thanks!

Checkbox: Checking If One Is Already Checked
Well I am having a small problem here that I don't quite understand.

I have two checkboxes, one named SubtractA and another SubtractB. What I want is that only one can be checked at a time. So if SubtractA is checked, SubtractB cannot be checked. Here is what I have:


VB Code:
Private Sub SubtractA_Click()If SubtractB.Value = 1 ThenSubtractB.Value = 0End IfSubtractA.Value = 1End Sub Private Sub SubtractB_Click()If SubtractA.Value = 1 ThenSubtractA.Value = 0End IfSubtractB.Value = 1End Sub


That should work, except when I check one, then check the other I get an error stating "Out of stackspace", what does that mean?

Check If Db Checkbox Is Checked
Hey, i cant figure out how to check if a checkbox in my database is checked or not I've tried:

if rs.fields("Car_HiredOut") = 1 then
if rs.fields("Car_HiredOut") = "1" then
if rs.fields("Car_HiredOut") = Yes then
if rs.fields("Car_HiredOut") = "Yes" then
if rs.fields("Car_HiredOut") = vbchecked then

I just cant figure it out.

Anyone know?? Thanks

BIOSTALL

How To Test If CheckBox Is Checked?
I am reading several fields from an Access Database and displaying them in a listview. I do this with

Code:
Set itemTemp = lvMovies.ListItems.Add(, , rs(0).Value)
itemTemp.SubItems(1) = (rs(1).Value)
itemTemp.SubItems(2) = (rs(2).Value) ' This the checkbox.value


This works fine. I now want to display all line items of the first listbox in another listbox based on the value of a checkbox in Access. My question is simle, How do I test if the checkbox in Access is checked or or not?

Thanks in advance

Charles

Percentage Of Checkbox That Checked
any1 know how to do it?

i try to calculate the count of checkbox that checked from my crew data..

plz help me in coding

Checkbox Does Not Retain Value/stay Checked
I have a VBA user-form in Excel with checkboxes..If the user checks the checkbox, it shows additional details by unhiding rows, uncheck and the rows rehide

The code looks like this:

Private Sub CheckBox1_Click()

Application.Goto Reference:="Someextradetail"

If CheckBoxPOH = False Then
Selection.EntireRow.Hidden = True
Else
Selection.EntireRow.Hidden = False
End If

End Sub

So, some rows start out hidden, then are displayed if the user clicks the box.

The problem is when you close the user form, then open again, the box is no longer checked, but the rows are still displayed. So, if you want to hide again (the result of unchecking the box) you have to first check the box again, then uncheck.

Have I missed some propery setting for the checkbox in VBA?

Thanks in advance...

Sendkeys & Determine Checkbox Is Checked
Hi,
I can use the sendkeys with tabs to navigate to a checkbox in a different application. My question is how could I detect whether that checkbox is checked or not?

Thanks,

PhiL

Sendkeys & Determine Checkbox Is Checked
Hi,
I can use the sendkeys with tabs to navigate to a checkbox in a different application. My question is how could I detect whether that checkbox is checked or not?

Thanks,

PhiL

Get Checked Items From ListBox With Checkbox
I have a ListBox with Style selectd to 1 ie with check box.
How do i get all the checked items from the list?
I tried the follwoing code it is returning only the selected item...not the all the chekced items..

Code:
Private Sub MiscList_LostFocus(Index As Integer)
MsgBox "Number of checked items = " & MiscList(Index).SelCount
For i = 0 To MiscList(Index).SelCount
'If MiscList(Index).Selected(i) Then MsgBox MiscList(Index).Text
MsgBox " checked items IS " & MiscList(Index).Text


Next i

Getting The Label Caption Of A Checked Checkbox
There is a nifty way to get the label of a checked checkbox in a frame in a form in Access. There is one part that I can't get working though.

Code:
Private Sub fraOperator1_Click()
    
    Dim ctl As Control
    Dim chk As CheckBox
    Dim intCount As Integer
    Dim intCounter As Integer
    
    If Me.fraOperator1.Value = 1 Then
        Me.fraOperator0.Value = 2
    ElseIf Me.fraOperator1.Value = 2 Then
        Me.fraOperator0.Value = 1
    End If
    
    For Each ctl In Me.fraOperator1.Controls
        If ctl.ControlType = acCheckBox Then
            Set chk = ctl
            If chk.Value = -1 Then
                Debug.Print chk.Controls(0).Caption
            End If
' intCount = ctl.Properties.Count
' For intCounter = 0 To intCount - 1
' Debug.Print ctl.Properties(intCounter).Name
' Next intCounter
        End If
    Next ctl
End Sub


I get Quote:Run-time error 2427: You entered an expression that has no value at the bold, red line.

I have also tried Code:If ctl.Value = -1 Then but I get the same error.

Oddly enough, I ran the commented out code and got the following 34 properties - non of them the Value property!

Code:
EventProcPrefix
Name
ControlType
OptionValue
StatusBarText
Visible
DisplayWhen
Enabled
Locked
Left
Top
Width
Height
SpecialEffect
BorderStyle
OldBorderStyle
BorderWidth
BorderLineStyle
BorderColor
ShortcutMenuBar
ControlTipText
HelpContextId
Section
Tag
InSelection
OnGotFocus
OnLostFocus
OnMouseDown
OnMouseMove
OnMouseUp
OnKeyDown
OnKeyUp
OnKeyPress
ReadingOrder






Edited by - Geof on 3/14/2006 10:11:59 AM

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??

Checking If A Checkbox Is Checked, And If It Is, Enabling A Frame?
This is probably a really simple question, but I have never worked with check boxes before. What I simply want, is when a Check Box is ticked, a frame will be enabled. When it is not, it will be disabled.

Thanks

Close On Program Startup If Checkbox Is Checked.
I am making a disclaimer with my program. I want to make it so it starts up with my program which I know how to do. But see i need to figure out how to make checkbox that if you click it the disclamer form never shows again. I know how o use the savesettings and getsettings but if i put the getsettings in the form load funtion it returns an error saying object required. I think it is because there is no previously saved data in the hkey. So how can i ensure it checks the check box but also returns no error?

EDIT:
I edited my code so so its like this:


VB Code:
Private Sub Form_Load()FrmClientMain.ShowCheck1.Value = GetSetting(App.EXEName, "Disclaimer", "Check1", 0)If Check1.Value = 1 ThenMe.HideEnd IfEnd Sub Private Sub Form_Unload(Cancel As Integer)SaveSetting App.EXEName, "Disclaimer", "Check1", Check1.ValueEnd Sub

If Checkbox Checked And Item Not Selected From ListBox BUT...
I have a checkbox and a combobox working together where if the checkbox (commute) is checked but nothing is selected from the list (car, bus, carpool, ferry, etc.) I have a code like this:

If chkCommute.Value And cboCommute.ListIndex = -1 Then 'checked but nothing selected in listbox
MsgBox "You must select a mode of transportation or enter another mode", , "Missing Info"'select a mode since you checked the box
cboCommute.SetFocus
Exit Sub
End if

And it works fine but I want it to go the opposite way - if a mode of transportation is selected but the checkbox not checked THEN...whatever. This info goes to an array that gets printed out. If I select a mode of transportation but don't check the checkbox and press enter the mode of transportation won't show up on the list. What would be a good way to make it come out? Anyone up for this? Thanks.

How Do I Use VB To Tell If A Checkbox Is Checked INSIDE And Excel Sheet?
Thanks ahead of time for any help you can give.

I am trying to link my VB program to an Excel Spreadsheet and see if a box is checked or unchecked. Here is the erroring code I have right now.

It always says "Object doesn't support this property or meathod"


Thanks again,
Willz99ta

Code:
Private Sub check_Click()
    
Dim CortsExcel As Excel.Application
Dim wbOutput As Workbook
Dim wsOutput As Worksheet
    
Dim Directory As String

Directory = "C:Documents and SettingswhowardDesktopPrograms WrittenCORTS Automate est200503290102456.xls"

Set CortsExcel = CreateObject("Excel.Application")
CortsExcel.DisplayAlerts = False
Set wbOutput = CortsExcel.Workbooks.Open(Directory)
Set wsOutput = wbOutput.Sheets(1)
    
    



If wsOutput.ChartObjects.CheckBoxes(7) = True Then
    Text1.Text = Yep
ElseIf wsOutput.ChartObjects.CheckBoxes(7) = False Then
    Text1.Text = Nope
End If



wbOutput.Close
CortsExcel.Quit
End Sub

Make A Listbox With Checkbox Checked When Adding An Item
Hi, this is a very simple question but i have a hard time figuring out.
How do I make an item automatically checked when I add an item in a listbox with checkbox inside?

Thanks.

Keeping A Checkbox Checked Even When You Close And Open The Program
I want to be able to make one of my checkmark boxes that are checked stay checked and if it is not checked, stay not checked (I'm talking about when you close and open the program, its state stays the same). Also I need to be able to decrypt what is in the textbox...If you need to know this is an option to save the password, and Ive already got it to save to an ini file but I need to encrypt that and have the program decrypt that. Any help?

Mixed State Checkbox
I thought a checkbox was either checked or non-checked
can someone explain the mixed state checkbox to me?
Thanks.

Set Initial State Of CheckBox?
Is it possible to set a CheckBox in Excel to be unchecked every time the workbook is opened?

My CheckBox reveals instructions for a user to follow - so I obviously want the text hidden each time they open the workbook.

Any ideas?

GH

Changing Checkbox State
Hi

I am looking for a way to change the state of a checkbox from true to false or vice versa without triggering the click event for the checkbox. Does anyone know of a way to do this?

I am using Excel 2000.

Thanks

Michael

Save Checkbox State
I have a form with 4 checkboxes (frmOptions)
I need to be able to click a Command button (Apply) and have the state of the boxes (checked or not) saved to either a config file or registry so the next time my app is started the checkboxe states are the same.

Save Checkbox State
Hi, I want to save the state of a checkbox ie.. if checked save it and when app restarts the checkbox is checked.

thanks

David

Treeview Checkbox State
Hi all,

Why my treeview checkbox will not show checked/unchecked state when check boxes come back after hided (when treeview.checkboxes becomes true)? If that is the way it is, how can I set these check boxes to their correct state by VB code? Thanks.

Setting The Initial State Of A Checkbox
Every time a user opens my workbook I want the CheckBox to be unchecked.

I can do this using a CheckBox from the Control Toolbox. I use this code:

Sheet1.CheckBox1.Value = 0

However, I'm having to use a CheckBox from Forms to ensure compatability with Excel 95 (ie not using Active X)

If I use this code to set the initial state of the checkbox to being unchecked then I get a "424 Object expected" runtime error:

CheckBox60.Value = 0

Does anyone know what the correct syntax would be?

Hope someone does - My Windows 95 client is expecting this by Saturday.

GH

Finding Out Current State Of 'CheckBox'
Hello,

Since I am beginner, My question is elementary.
I want to display the current state ( checked, Unchecked or disabled )
of a 'CheckBox' in a 'TextBox' control, after pressing a 'CommandButton'.

Could you please help me?

Regards,

Checkbox State Depending On Cell Value
Hello,

The problem i want to be solved is:
On a worksheet are 31 checkboxes, there are 31 cells with or without a value. If the cell value is null/empty the depending checkbox must be unchecked, else the checkbox must be checked.

I've searched this forum, but i didn't find the information to solve it. The thread
I had thought of an for.. next loop

vb:
cells(1,1).select
for i=1 to 31
if cells(1+i,1) then
checkbox(0+i).value=true <-- Invalid code that's
where i need help
cells(1+i,4)= aValue
else:
checkbox(0+i).value=false
end if
next i

in the thread below is a simular problem, i don't understand the script.
http://www.xtremevbtalk.com/show...light=checkbox

thnx,

Werner

Setting The Initial State Of A Checkbox?
Every time a user opens my workbook I want the CheckBox to be unchecked.

I can do this using a CheckBox from the Control Toolbox. I use this code:

Sheet1.CheckBox1.Value = 0

However, I'm having to use a CheckBox from Forms to ensure compatability with Excel 95 (ie not using Active X)

If I use this code to set the initial state of the checkbox to being unchecked then I get a "424 Object expected" runtime error:

CheckBox60.Value = 0

Does anyone know what the correct syntax would be?

Hope someone does - My Windows 95 client is expecting this by Saturday.

GH

Grayed State In Treeview Checkbox
As there are three states in the chechbox control(checked,unchecked and grayed) ,can we have the third state (using any api call) in the treeview with checkboes.
Please help me do this.
Regards
Sravanthi

Get Radio Button Or Checkbox State Using FindWindowEx?
How should i find the state of the button? what should i look for?
I'm trying to finish a prev thread about winamp module. This will be used to check if the "ID3v&2 Tag" button is enabled or not.


VB Code:
hwnd_TmpText = FindWindowEx(hwnd_InfoBox, 0, "Button", "ID3v&2 Tag")    TextLen = SendMessageS(hwnd_TmpText, WM_GETTEXT, Len(TmpText), TmpText)' using this, TextLen has ID3v&2 Tag as text always, that is correct, but i wanted to look the button state in this case and not getting it's label.    If TmpText = False Then    MP3Info.id3v2 = False    Else:    MP3Info.id3v2 = True    End If


Any idea how may i do this?

Checkbox State Saved To Sequential Text File
I need to save the state of some checkboxes to a sequential textfile. I am getting a type mismatch when I read the state back out of the file as a string(true or false) and try to assign it to the checkbox on my form. What type of Variable should I be using?

Here is what I'm trying.....

To get the state from the form:

dim FL as string

if checkFL.value then
FL$="true"
else: FL$="false"
end if


Once ive read the file and retreived it as a string, to assign it back to the checkbox:

checkFL.value = FL$

- this statement gives me a type mismatch when run. How should this be done?

Much Thanks for the help......Larry

ListView Toggle Icon
Hi all,

I am using a listview control in report view.

I have 2 icons in an image list bound to the listview.
Depending on a certain criteria, a listview item will be assigined a small icon index of 1 or 2 (where 1 = on an 2 = off). I also have full row select set to true.

Now, what I want to happen is this:

When a user clicks an item, the smallicon will change or toggle.

I am using the following code:


Code:
Private Sub lvwMain_ItemClick(ByVal Item As MSComctlLib.ListItem)

With Item
If .SmallIcon = 1 Then
.SmallIcon = 2
Else
.SmallIcon = 1
End If
End With

End Sub



Here is the problem:

If I click on the small icon, the toggle works fine however if clicked anywhere else on the selected row, the icon toggles and then toggles back to its original state. It is like the item click event is firing twice in this instance.

It seems a pretty simple thing to achieve but have not been able to figure it out yet.

Any help is most appreciated.

Cheers

Jack

Toggle ListView Selection
Hi Gurus,

I'd like to make toggle type selection of ListView.
In other words, If click one item, that is selected.
And click another selected item, that should be unselected.
Is this possible?
Could anyone who know this let me know?

Listview Checked
hi..
in Adodb connection to access. how to have all the checked items in listview move with the record?

Listview Checked
Example:
1 Listview-- all items of listview are with checkboxes.
Now, if I click on command button, the program must take only item checked and position on table of Access.

Help me!!

Get Value From Checked Listview
Hello guys...
How to get value from checked rows in Listview?

Example;

ID Name
01 John
02 Joe
03 Matt
04 Bill
05 Paul

Private Sub cmdDelete_Click()
' get ID from checked rows
End Sub

Please advice me.

Listview Checkboxes Checked
I have a listview with checkboxes that gets populated when the user clicks a button.

The user can then check certain records in the listview and click another button and more information for the selected recs are displayed (in another listview). Now, on the first click, the second listview is empty. So, I go back and do it again and then it works! This is how I'm doing it, but maybe there's a better way?


Code:
With ListView1
For i = 1 To .ListItems.Count
If .ListItems(i).Checked = True Then
ACCESSdb.Execute "INSERT INTO temp values ('" & ListView1.ListItems(i) & "')"
End If
Next
End With

For Each tb In ACCESSdb.TableDefs
If tb.Name = "ChosenEQTypes" Then
ACCESSdb.Execute "DROP TABLE ChosenEQTypes"
End If
Next
ACCESSdb.Execute "SELECT EqSummary.EQNUM, EqSummary.EQTYPE, EqSummary.DESCRIPTION AS Type INTO ChosenEQTypes FROM EqTypeSummary INNER JOIN (EqSummary INNER JOIN temp ON EqSummary.EQTYPE = temp.EQTYPE) ON EqTypeSummary.EQTYPE = EqSummary.EQTYPE"

setListView2 'this sets up the datasource and column sizing, etc...

Copyright 2005-08 www.BigResource.com, All rights reserved