Solved

Copy a DBGRID1 selectedrow to a DBGRID2

Posted on 2001-08-17
13
565 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:pfjvisser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
13 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6397347
I assume that DBGrid2 is unbound?

0
 

Author Comment

by:pfjvisser
ID: 6397366
Yes tim, it just for temp. rows. I need to make a selection
for generating MS word letters from some adres ranges.
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 40 total points
ID: 6397396
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pfjvisser
ID: 6397441
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
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6397464
       For j = 0 To fromgrid.Cols - 1
        fromgrid.Col = j
        togrid.Col = j
        togrid.Text = fromgrid.Text
        Next
       
       
       
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6397469
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
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6397482
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
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6397486
as Tim said their is no other way to go about it
0
 

Author Comment

by:pfjvisser
ID: 6397498
Whel harsh, Is this VB6 coding.
I have to try see if it works
0
 

Author Comment

by:pfjvisser
ID: 6397509
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 6397540
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
 

Author Comment

by:pfjvisser
ID: 6397559
Yes Tim. I think that your right. I give your coding a try
Here are the points my vriend..

PS Harsh thanks also..
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6397582
You are welcome.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question