Link to home
Start Free TrialLog in
Avatar of Altaf Khan
Altaf Khan

asked on

trying to transfer entire mshflexgrid row to another mshflexgrid row

hello 

Want to transfer entire a row which have first column value = textbox1 from mshflexgrid_src to mshflexgrid_dest and want to remove it from mshflexgrid_src  and show that records on top row in mshflexgrid_dest

using vb6.0 


so far i tried

    With mshflexgrid_dest 

        A = mshflexgrid_dest.rows - 1
        B = mshflexgrid_src .RowSel


        For J = 1 To MSHFlexGrid_src.Cols - 1
            If Val(MSHFlexGrid_src.TextMatrix(J, 1)) = Val(Text8.Text) Then
MSHFlexGrid_src.TextMatrix(1, 0)
                    MSHFlexGrid_dest.TextMatrix(1, 1) = MSHFlexGrid_src.TextMatrix(1, 1)
                    MSHFlexGrid_dest.TextMatrix(1, 2) = MSHFlexGrid_src.TextMatrix(1, 2)
                    MSHFlexGrid_dest.TextMatrix(1, 3) = MSHFlexGrid_src.TextMatrix(1, 3)
                    '''and more coolumns
                    Exit For
            End If
        Next J
        
    End With


Open in new window

Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Hmm, are you aware that Microsoft deprecated HFlexgrids due to security breach ?
Private Sub cmdMove_Click()
Dim lngCol As Long
Dim lngRow As Long

With MSHFlexGrid_src
    For lngRow = 0 To .Rows - 1
        If .TextMatrix(lngRow, 0) = Text1.Text Then
            MSHFlexGrid_dest.AddItem "", 0
            For lngCol = 0 To .Cols - 1
                MSHFlexGrid_dest.TextMatrix(0, lngCol) = .TextMatrix(lngRow, lngCol)
            Next
            .RemoveItem lngRow
            Exit Sub
        End If
    Next
End With
End Sub

Open in new window

And here is a zip file containing the project.
29233112.zip
Avatar of Altaf Khan
Altaf Khan

ASKER

Thanks Martin For Reply
1, Zip File is empty,
2, On this Line Getting an error if SrcGrid have 2 row, 1 Fixed and 1 with data.
.RemoveItem lngRow

Open in new window

error is
Run Time Error '30015'
Can Not Remove Last Known-fixed row
and how to display Hierarchy  data in MSHFlexGrid_dest with two table with one common field..?

i tried this but getting error
sCmd = "SHAPE {SELECT CnmNo, BoDate FROM CusTBL} " _
        & "APPEND ({SELECT CnmNo, ArtName, Qty FROM OrdTBL} " _
        & "AS chapOrders " _
        & "RELATE CnmNo TO CnmNo)"
  
   ''''Getting Error "Syntax error or access violation" on following line
    rst.Open sCmd, con, adOpenStatic, 2

Open in new window




Do you want to be able to move the fixed row? Does MSHFlexGrid_dest have one?
if MSHFlexGrid_dest have empty fixed row and empty data row then yes need to move fixed row also..
Okay then if we move the fixed row to dest, do you want the old src row 2 (which has become row 1) to be fixed?
no, there is  field name , like
first column name GRNo, BkgDt, Destination, FromStn, ...........etc....

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks
i just did this..

For lngCol = 1 To .Cols - 1
   MSHFlexGrid_dest.TextMatrix(1, lngCol) = .TextMatrix(lngRow, lngCol)
Next

If lngRow = 1 Then
   For lngCol = 1 To .Cols - 1
     MSHFlexGrid_src.TextMatrix(1, lngCol) = ""
   Next
Else
   .RemoveItem lngRow
End If

Open in new window


like there is 16 column then do i have to mentioned each column name..?
MSHFlexGrid_src.TextMatrix(1, lngCol) = ""
.RemoveItem lngRow won't work if that row is fixed. Plwaaw see lines 12 to 14 in my latest code.
like there is 16 column then do i have to mentioned each column name..?
I guess there are things that you want to do that you haven't told me about. Please supply a sample project in a zip file and all the requirements.
ok done,
if src_grid have two row one with data and one fixed then
after moving row with data updating all records from src_grid  (User part done here)
next time when user click on NewRecbutton then grid refreshed and getting fixed row with titles

Thank you so much Martin  :-)



(now how to display Hierarchy  data in MSHFlexGrid_dest with two table with one common field..?
for this do i have to ask another question..??)
for this do i have to ask another question..??)
Yes, but please don't forget to close this question first.
Thank you for the testimonial and I’m glad I was able to help.

If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015 and 2017
              Experts Exchange Distinguished Expert in Excel 2018 and 2021
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
              Experts Exchange Top Expert VBA 2018 to 2020