1,105,402 Community Members

Transfer row data from one mshflexgrid to another mshflexgrid

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello everyone. Here is the code first

Private Sub Grid1_Click()
Dim i As Integer, j As Integer
Grid2.Cols = Grid1.Cols
Grid2.Rows = i + 1
C = Grid1.Row
For j = 0 To Grid1.Cols - 1
Grid2.TextMatrix(i, j) = Grid1.TextMatrix(C, j)
Next j
i = i + 1
End Sub

what I am trying to do here is transfer data from grid1 to grid2. This code is transferring the data, but the problem is:
1) after transferring one row data when I clicked another row of grid1, it just change the existing data of the grid2 to current data. What I want here is to transfer it into next row of grid2 insted of replacing it with the previos row.
2) the first row of grid2 is suppose to hold the headings but the data is shifting to the first row, so I don't have any column heading there.

Hope I can make the qustion clear here. Any kind of help plz.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 
Grid2.Cols = Grid1.Cols

i = grid2.Rows

Grid2.Rows = i + 1
Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thnaks sir for replying. I have the following code now :

Private Sub Grid1_Click()
Dim i As Integer, j As Integer
Grid2.Cols = Grid1.Cols
i = Grid2.Rows
Grid2.Rows = i + 1
C = Grid1.Row
For j = 0 To Grid1.Cols - 1
Grid2.TextMatrix(i, j) = Grid1.TextMatrix(C, j)
Next j
i = i + 1
End Sub

it has solved my two problems but adds a new one. Now I am having a extra row next to my heading of the grid. I mean when I click the grid1 row it adds to grid2 but after leaving an empty row above it. Should I cut something from my code ??

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Not sure what you mean. Take a picture and post that for me, thanx.

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i m uploading the image as attachment here. data is going from sales details to change details. There is a extra row created i change details above the transferred data row. sales_return

Attachments
Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

Try :

Private Sub grid1_Click()
    With grid2
        a = grid2.Rows - 1
        b = grid1.RowSel

        For j = 1 To grid1.Cols - 1
            grid2.TextMatrix(a, j) = grid1.TextMatrix(b, j)
        Next j
        .AddItem ""
    End With
End Sub
Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
1
 

And that solves the problem, thanx JX. :)

Merry Christmas and happy new year so by the way.

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks for the solution JX Man. Although it solves the problem other way around. I mean now when I click a row in grid1 it went to grid2 adding an extra row after the transferred data row, before it was happening an extra row before the data row (as per the picture of my last post), now it is adding an extra row after the data row. I don't know will it be solved or not properly or anything I am doing wrong, but thanks anyway.

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

I think Without a new row your no 1 problem will appear again.

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Then now I have to be statisfied with an extra row after the data row.

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

is there any other way, I mean using a data-grid or listview or anything elese can solve the problem ??

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

it looks like i m all alone now, as nobody is answering my questions.

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

What you mean about using datagrid or listview?
Transfered it from flexgrid to datagrid/listview or using datagrid/listview for all operation?

Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

what would be the easiest ? Although I have used MSHFlexgrid mostly in this program, but if in this situation any alternative can bring good result, I like to go for it.

Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

Well,,you're the one who know which the best.
I give an example of trasnferin data from flexgrid to listview & datagrid.
Modified it as u needed
trasnfer

Attachments Transfer_One_Flexgrid_to_another_Flexgrid.zip (12.69KB)
Member Avatar
silversurf
Junior Poster in Training
96 posts since Jul 2012
Reputation Points: 12 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks for you attachment and advice. I have used two listview to accomplished the task, till now I am satisfied. Thanks again.

Question Answered as of 1 Year Ago by Jx_Man and AndreRet
Member Avatar
mushtaqueahmed.chandio
Newbie Poster
2 posts since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
Dear friends
i am making inventory management i have one problem when i have purchase product form its working successufully. other form is edit purchase order. when i click update it does not save. please any one can help me? here is code

private cmdsave_click()
Dim dd1 As Database
Dim mi1 As Recordset
Dim count As Integer
Dim gg As Variant
dbname = App.Path + "\data\database.mdb"
Set dd1 = OpenDatabase(dbname)
Set mi1 = dd1.OpenRecordset("select * from purchase")
bir.Row = 1
bir.Col = 0
    If bir.Text = "" Then
MsgBox "Please enter complete detail.", vbExclamation
Else
For count = 1 To bir.Rows - 2
    bir.Row = count
mi1.Edit
    bir.Col = 0
    mi1.Fields("proid") = bir.Text
    bir.Col = 1
    mi1.Fields("name") = bir.Text
    bir.Col = 2
    mi1.Fields("packing") = bir.Text
    bir.Col = 3
    mi1.Fields("packtype") = bir.Text
    bir.Col = 4
    mi1.Fields("weight") = bir.Text
    bir.Col = 5
    mi1.Fields("ip") = bir.Text
    bir.Col = 6
    mi1.Fields("tp") = bir.Text 
    bir.Col = 7
    mi1.Fields("purqty") = bir.Text
    bir.Col = 8
    mi1.Fields("purbonus") = bir.Text
    bir.Col = 9
    mi1.Fields("disper") = bir.Text
    bir.Col = 10
    mi1.Fields("disrs") = bir.Text
    bir.Col = 11
    mi1.Fields("wto") = bir.Text
    bir.Col = 12
    mi1.Fields("total") = bir.Text
    bir.Col = 13
    mi1.Fields("discount") = bir.Text
    bir.Col = 14
    mi1.Fields("netamount") = Val(bir.Text)
bir.Col = 15
mi1.Fields("bonusamount") = Val(bir.Text)
bir.Col = 16
mi1.Fields("wtoamount") = Val(bir.Text)
'bir.Col = 17
mi1.Fields("purid") = Combo1.Text
mi1.Fields("purdate") = Label2.Caption
mi1.Fields("company") = Label6.Caption
mi1.Fields("supaddress") = Label7.Caption
mi1.Fields("supphone") = Label8.Caption
mi1.Fields("supfax") = Label15.Caption
mi1.Fields("supemail") = Label11.Caption
mi1.Fields("supwebsite") = Label12.Caption
mi1.Fields("groupname") = Label10.Caption
mi1.Fields("guid") = Label16.Caption
mi1.Fields("comid") = Label14.Caption
mi1.Update
Next
bir.Clear
bir.FormatString = "Item No | Item Name |Pack Size |Pack Type |Weight |I.Price |T.Price |Qty |Bonus |Dis % |Dis $ |W T O |TOTAL |DISCOUNT |NET AMOUNT |BONUS AMOUNT |WTO AMOUNT"
bir.Rows = 2
End If
Unload Me
Me.Show
End Sub
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article