Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Datagridview1
DUE_DATE    OPB
10/20/14    1000
11/20/14    2000
12/20/14    3000
1/20/15     4000
2/20/15     5000
3/20/15     6000

Datagridview2
MONTH_APPLIED    OPB
                 1500
                 3000
                 4500
                 6000

I need to select the DUE_DATE from Datagridview1 and put it in MONTH_APPLIED to Datagridview2

the output should be like this
MONTH_APPLIED    OPB
10/20/14         1500
12/20/14         3000
1/20/15          4500
3/20/15          6000

VB
If DataGridView2.Rows(0).Cells("OPB").Value > DataGridView1.Rows(0).Cells("OPB").Value Then
'what code should i put to get the output
            ElseIf DataGridView2.Rows(0).Cells("OPB").Value < DataGridView1.Rows(0).Cells("OPB").Value Then
'what code should i put to get the output
            End If
Posted
Updated 19-Oct-14 20:11pm
v3
Comments
Sinisa Hajnal 20-Oct-14 2:14am    
What is the join condition? That is, how can you relate table1 to table 2? In the above example only 3000 and 6000 are common to both tables.

Also, what have you tried?
Member 9663328 20-Oct-14 4:39am    
Actually Datagridview1 and Datagridview2 is in the same form so two tables show up im using this code to get the due date and put it in the month applied

DataGridView2.Rows(counter).Cells("MONTH_APPLIED").Value = (DataGridView1.Rows(counter).Cells("DUE_DATE").Value)

counter is + 1

in my code i get the rows in sequential

MONTH_APPLIED OPB
10/20/14 1500
11/20/14 3000
12/20/15 4500
1/20/15 6000

but i want it to be like this

MONTH_APPLIED OPB
10/20/14 1500
12/20/14 3000
1/20/15 4500
3/20/15 6000

Im thinking this has something to do with this code i just dont know how to get it.

If DataGridView2.Rows(0).Cells("OPB").Value > DataGridView1.Rows(0).Cells("OPB").Value Then
'what code should i put to get the output
ElseIf DataGridView2.Rows(0).Cells("OPB").Value < DataGridView1.Rows(0).Cells("OPB").Value Then
'what code should i put to get the output
End If

1 solution

Think of it! You should only "update" MONTH_APPLIED when values in OPB column are equal.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900