Solved

Copy a DBGRID1 selectedrow to a DBGRID2

Posted on 2001-08-17
13
529 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
  • 5
  • 5
  • 3
13 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
I assume that DBGrid2 is unbound?

0
 

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
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
 

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
       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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:harsh008_k
Comment Utility
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
Comment Utility
as Tim said their is no other way to go about it
0
 

Author Comment

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

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
You are welcome.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now