Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to compare the resutls of two grids

Status
Not open for further replies.

AFK1

IS-IT--Management
Aug 26, 2005
38
US
I ahve a problem. I have two gris. I need to compare the results of both grids and make sure that they look same. Lets say that I have 25 rows on Right hand side of grid, then I should have 25 on left.
Lets say I have 24 on left I need to capture that row's Id from Right and give message to user. Then add one row to Left.
Can some one help . I have tdb grid.
Thanks
 
Keep in mind that a grid is a display device ... not a data management device. If you are using recordsets as the data sources for your grids then you should be able to write some code (either VB or SQL) that will give you records that are in one data source but not the other.

RowID (from the .Row property) in a data grid just specifies a row number counting the first row in the grid as Row 0. That is not the same as a particular row of data in the data source for the grid because you can scroll the data source to different row positions in the grid.
 
Can you please give me example of the Code. How would you do it in vb.
 
I probably would
Code:
SQL = "Select A.KeyField " & _
      "From tbl1 As A LEFT JOIN tbl2 As B " & _
      "ON A.KeyField = B.KeyField " & _
      "WHERE B.KeyField IS NULL "

Dim Conn         As New ADODB.Connection
Dim rsDifference As New ADODB.Recordset

Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\SomeFolder\myDatabase.mdb;"

rsDifference.CursorLocation = adUseClient
rsDifference.Open SQL, Conn, adOpenDynamic, adLockOptimistic

Now the recordset rsDifference contains all the KeyFields in tbl1 that are not in tbl2. A similar approach, and the same SQL, can be used if you are using DAO rather than ADO.

That's the general pattern. Obviously you would need to modify this to use the data sources that apply to your specific situation.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top