Copy a DBGRID1 selectedrow to a DBGRID2

Hi
I have 2 DBGRIDS. I need to copy some selected rows from DBGRID1 to a DBGrid2. how can i do this. DBGrid1 is conected to a database object.

Thanks in advanced
pfjvisserAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
Do you have the second grid bound to anything? If you don't (and you will have to forgive me as I don't use DBGrid much) can you actually store records in it? If so then surely all you need to do is something like:

For i= 0 to Data1.Recordset.Fields.Count - 1
  DbGrid2.Somepropertyorother = Data1.Recordset.Fields(i).Value
Next
0
 
TimCotteeHead of Software ServicesCommented:
I assume that DBGrid2 is unbound?

0
 
pfjvisserAuthor Commented:
Yes tim, it just for temp. rows. I need to make a selection
for generating MS word letters from some adres ranges.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
pfjvisserAuthor Commented:
Whel tim. I thanks for the sample but i downt want it to loop. In need a Simpel row copy methode. You no some other way?

PS Sorry i'm from holland and my engles is not perfect.
0
 
harsh008_kCommented:
       For j = 0 To fromgrid.Cols - 1
        fromgrid.Col = j
        togrid.Col = j
        togrid.Text = fromgrid.Text
        Next
       
       
       
0
 
TimCotteeHead of Software ServicesCommented:
Other than a loop, not really. You are restricted to the capabilities of the objects, the DBGrid is only representing the underlying recordset in some fashion. If you were using the DataGrid with the ADO data control you could use the .GetString or .GetArray function to quickly grab a string from the record but the DAO based Data control doesn't have this as far as I know.
0
 
harsh008_kCommented:
Oops,This is the one

        fromgrid.Row = ur choice(Integer-Valid row no)
        togrid.Row = urchoice(Integer-Valid row no)
        For j = 0 To fromgrid.Cols - 1
        fromgrid.Col = j
        togrid.Col = j
        togrid.Text = fromgrid.Text
        Next
   
0
 
harsh008_kCommented:
as Tim said their is no other way to go about it
0
 
pfjvisserAuthor Commented:
Whel harsh, Is this VB6 coding.
I have to try see if it works
0
 
pfjvisserAuthor Commented:
I now. I had to build my database some other way. I need to
query te records and let the database "Access" copy them to
a temp Rec.Set. I think.
0
 
TimCotteeHead of Software ServicesCommented:
That would work, especially if you have unique identifiers for the rows, you could easily build a select into statement to create the temporary table and then bind the second grid to this table. You will still have to loop through the selected rows in grid 1 if there are multiple rows selected.
0
 
pfjvisserAuthor Commented:
Yes Tim. I think that your right. I give your coding a try
Here are the points my vriend..

PS Harsh thanks also..
0
 
TimCotteeHead of Software ServicesCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.