Solved

dynamic checkbox

Posted on 2007-03-19
3
194 Views
Last Modified: 2013-12-26
I have an app that pulls an id number and description.  This info pull from an sql server.  I also want to add a checkbox per each ID, how would I do this.
0
Comment
Question by:jduclosjduclos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jkaios earned 125 total points
ID: 18751449
Assuming that the name of your connection object is oCONN and the field names to retrieve from the table are ID and Description.

Now, the following example use the List View control in Microsoft Common Controls 6.0
Add a list view control to the form and then use the code below to populate it.
Rename [YOUR TABLE] to the actual name of your table.

Again, assuming that you have already made a connection to the database.
'---------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
   
   On Error Resume Next
   
   Dim rs As New ADODB.Recordset
   Dim xx As String
   Dim oItem As MSComctlLib.ListItem
   
   With ListView1
      .View = lvwReport
      .GridLines = True
      .LabelEdit = lvwManual
      .Checkboxes = True
      .FullRowSelect = True
      '---------------------
      .ColumnHeaders.Clear
      .ListItems.Clear
      '---------------------
      .ColumnHeaders.Add , , "ID#"
      .ColumnHeaders.Add , , "Description"
   End With
   
   xx = "SELECT ID, Description FROM [YOUR TABLE]"
   
   rs.Open xx, oCONN, adOpenForwardOnly, adLockReadOnly, adCmdText
   
   Do Until rs.EOF
      DoEvents
      Set oItem = ListView1.ListItems.Add
      oItem.Text = rs("ID")
      oItem.SubItems(1) = rs("Description")
      rs.MoveNext
   Loop
   
End Sub
'---------------------------------------------------------------------------------------------------------
0
 

Author Comment

by:jduclosjduclos
ID: 18772252
what about using a checklistbox, how would i use that with data from a MSSql table, and which is better dynamic checkboxes or the checklist box?
0
 

Author Comment

by:jduclosjduclos
ID: 18808998
Ok I have figured out what i needed to do for a dynamic checkedlistbox.
 'This is used populate the checklistbox
        Dim items As String
        Dim r As Integer = 0
        Dim c As Integer = 1
        While r < xResourceT.GetData.Rows.Count
            items = CStr(xResourceT.GetData.Rows(r).Item(c))
            xCLBResource.Items.Add(items)
            r = r + 1
        End While
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 - Convert HH:MM into Decimal 8 75
Export Data to Different .csv Files 27 131
Sub or Function is not defined 6 59
checkbox to hide entire section 10 74
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question