Solved

Select rows in a DBGrid.

Posted on 1997-07-23
3
253 Views
Last Modified: 2006-11-17
Hi experts,

How to select / highlight a set of continued records in a DBGrid by mouse clicks and let the program know what are selected? I can't find anything representing the selected row numbers in the DBGrid.

Thank you.
0
Comment
Question by:victorlong
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
y96andha earned 50 total points
ID: 1428757
Use the SelBookmarks property. This comes directly from the online help:

Returns a collection of bookmarks for all selected records in the DBGrid control.

Syntax

object.SelBookmarks

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

When a record is selected in the DBGrid control, its bookmark is appended to the collection returned by the SelBookmarks property.  For example, if you create a clone of the Recordset object created by the DBGrid control, you can process individual data records by repositioning the cloned Recordset with bookmarks taken from the SelBookmarks collection.  

0
 

Author Comment

by:victorlong
ID: 1428758
Hi y96andha...(Sorry, not your first name :-)),

Thank you for your reply and help. You may know I am a beginer...I still not really understand:

1) When select the rows in a DBGrid, I can't find the way like sececting continued files in Windows by Shift + Click.
2) What the DBGrid.SelBookmarks really represents? Is that the row numbers or need to add another dot and somthing like DBGrid.SelBookmarks(i).row

Cheers.

Victor
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1428759
This is a code sample to get a selected record:

dim rs as recordset
rs = dbgrid1.recordset.clone
rs.bookmark = dbgrid1.selbookmarks(1)

rs is now positioned at the first selected record of the DBGrid.




0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

911 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

20 Experts available now in Live!

Get 1:1 Help Now