Solved

Select rows in a DBGrid.

Posted on 1997-07-23
3
249 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

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

6 Experts available now in Live!

Get 1:1 Help Now