Solved

data-bound grid with selectable column

Posted on 2003-11-30
8
660 Views
Last Modified: 2013-12-25
Hey
I'm currently working on an application (VB6) that uses an Access database for its data. I have tried and tried to be able to have a selecteble column in a Flex Grid and Hierarchial Flex Grid, but have not been successful.

The basic idea is that i can select the first column of a row from the flexgrid. and the flexgrid will put a tick or leave it unticked (True/False type thing), furthermore i need it to be able to change the underlying Access database field (which is a true/false field), either by code or not.
From the selected (ticked) rows i call some reports from the database and display them to the user (this part fine, can do this)

So does anyone know of a way of doing this? or is there a different control that can handle this.
btw i've tried CoolFlex, which works to an extent however would rather a data-bound version.

Thanks in advance for your assistance.
Regards
David
0
Comment
Question by:gumbyss
  • 6
  • 2
8 Comments
 
LVL 8

Expert Comment

by:MYLim
ID: 9848196
you got to use ListView control...
0
 
LVL 8

Expert Comment

by:MYLim
ID: 9848218
inside "mirosoft common control 6.0" then code will like below:
formload()
me.ListView1.Checkboxes=True
0
 
LVL 8

Accepted Solution

by:
MYLim earned 500 total points
ID: 9848273
'Below are code to load data,Modify to suite your code.Pls wait for "update" code...
'Remember to reference microsoft ActiveX data Object 2.7 library...

Private Sub Form_Load()
    Listld.Checkboxes = True
    Call LoadChk
End Sub

Private Sub LoadChk()
On Error GoTo ErrFound
Dim G, H As Integer
Dim item As ListItem
Dim CnnList As ADODB.Connection
Dim RsList As ADODB.Recordset
Dim StrSql, StrCnn, SQL As String
   
    StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ZDbGridTest\test1.mdb;User Id=admin;Password=;"

    StrSql = "Select * from yourTable"
   
       Set CnnList = New ADODB.Connection
       CnnList.CursorLocation = adUseClient
       CnnList.Open StrCnn

        Set RsList = New ADODB.Recordset
        RsList.CursorType = adOpenStatic
        RsList.CursorLocation = adUseClient
        RsList.LockType = adLockOptimistic
        RsList.ActiveConnection = CnnList
        RsList.Open StrSql

Listld.View = lvwReport
Listld.ListItems.Clear
Me.Listld.ColumnHeaders.Clear

For H = 0 To RsList.Fields.Count - 1
    Listld.ColumnHeaders.Add , , RsList.Fields(H).Name
    Debug.Print RsList.Fields(H).Name
Next

While Not RsList.EOF
Set item = Me.Listld.ListItems.Add(, , RsList.Fields(0))
    For G = 1 To RsList.Fields.Count - 1
    item.SubItems(G) = RsList.Fields(G) & " "
    Next
    RsList.MoveNext
Wend

RsList.Close
Set RsList = Nothing

CnnList.Close
Set CnnList = Nothing

Exit Sub
ErrFound:
MsgBox "Error Source : " & Err.Source & "; Error description : " & Err.Description, vbCritical, Err.Number
End Sub



0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:gumbyss
ID: 9848313
Have created a 'test' project and so far so good, look to be the way i want it.  
So thanks for that

As requested i will wait for the update code....

Really big thanks so far :D
0
 
LVL 8

Expert Comment

by:MYLim
ID: 9848761
'sorry,my wingate server have little problem...
'Please move 2 line of code to form general section:
'Dim CnnList As ADODB.Connection
'Dim RsList As ADODB.Recordset
'----------------------------------------------------------
'Please move 4 line of code to form_unload()
'RsList.Close
'Set RsList = Nothing
'CnnList.Close
'Set CnnList = Nothing

Private Sub Command1_Click()
Dim i As Long
i = 0

'Debug.Print "Index : " & Listld.ListItems.Count
RsList.MoveFirst
For i = 1 To Listld.ListItems.Count
'Debug.Print "----------------------------------------"
    Listld.ListItems.item(i).Selected = True
   
    If Listld.ListItems.item(i).Checked = True Then
        'Debug.Print "Checked = TRUE"
        RsList.Fields("student").Value = 1
    Else
        'Debug.Print "NOT CHECKED"
        RsList.Fields("student").Value = 0
    End If
    RsList.MoveNext
Next i

End Sub
0
 
LVL 8

Expert Comment

by:MYLim
ID: 9848797
Lastly,Please post your result...
0
 
LVL 1

Author Comment

by:gumbyss
ID: 9854597
Again Thanks for all you help...i've been able to adapt it to suit what i required. was a vary detailed answer.  So A big thanks

You should have already gotten the 500 points :D
0
 
LVL 8

Expert Comment

by:MYLim
ID: 9854639
thank's
q(^ _ ^)p
regards:
Mike
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 39
Passing a Text Box name to a Sub 6 96
Problem to With line 4 57
Advice in Xamarin 21 79
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

809 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