troubleshooting Question

vb6 update added data grid column

Avatar of Dee
DeeFlag for United States of America asked on
Visual Basic Classic
52 Comments1 Solution1370 ViewsLast Modified:
I have an unbound data grid (Janus gridex).

I am trying to add a column and add data to the new column, row by row.

The * asterisk I am entering in the following code, ends up populating only the last cell.  ie, I end up with an asterisk in the new column on the last row only. How do I write data to each row in the new column?
Private Sub Command1_Click()
    'Add a column to datagrid and update
    Dim i As Integer
    Me.DG.Columns.Add ("Late")
    For i = 1 To DG.RowCount
        Me.DG.Row = i
        'if condition then
            Me.DG.Value(3) = "*"
        'End If
End Sub

Here's is the code that builds the datagrid
Private Sub Command2_Click()

    Dim sqry As String
    Dim rc As ADODB.Recordset
    sqry = "SELECT CONVERT(VARCHAR(10), DAP_PARTNERS.DATE_PLACED,102) as date, COUNT(*) as count " & _
    "FROM DAP_PARTNERS INNER JOIN fuji_Orders ON DAP_PARTNERS.PO = fuji_Orders.Partner_OrderID " & _
    "WHERE (((DAP_PARTNERS.CUST_ID)='116927' Or (DAP_PARTNERS.CUST_ID)='DP0291') AND " & _
    "((DAP_PARTNERS.FS_Status)<'5') AND ((fuji_Orders.BrandingID)=2) AND ((fuji_Orders.OrderSource)=1)) " & _
    Set rc = New ADODB.Recordset
    rc.Open sqry, conSQL, adOpenStatic, adLockOptimistic
    If DG.Columns.Count < rc.Fields.Count Then
        Dim i As Integer
        For i = (DG.Columns.Count + 1) To rc.Fields.Count
            DG.Columns.Add rc.Fields(i - 1).Name, jgexText, jgexEditTextBox, rc.Fields(i - 1).Name
    End If
    DG.ItemCount = rc.RecordCount
    DG.Col = 1
    DG.Row = 1
    Dim iR As Single
    Dim iC As Single
    Dim GRS As Recordset
    Set DG.ADORecordset = rc
    Do While Not rc.EOF
      iC = 1
      For i = 0 To rc.Fields.Count - 1
         DG.Value(i + 1) = rc.Fields(i)
        Set rc = Nothing

End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 52 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 52 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros