[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

dynamic checkbox

Posted on 2007-03-19
3
Medium Priority
?
200 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 375 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

649 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