[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Datagrid Control - Error: The current row is not available

Posted on 2004-04-29
1
Medium Priority
?
1,211 Views
Last Modified: 2013-12-25
Hello,
       I have a couple of questions....
       1) I am using a Datagrid Control which is populated from a database. When i close the form i get an Error - "The current row is not available". The datagrid control is not editable. When i debug through the form, i do not get this error or when the entire row is selected.
       2) I want to be able to select an entire row when clicking on any field. Is this possible?

Thank you for your help.
0
Comment
Question by:ppseeth
[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
1 Comment
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 10955751
1) http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20749316.html

2) Here is the required code for that:

Option Explicit

Dim rstX As ADODB.Recordset

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    With DataGrid1
        ' Remove previously saved bookmark from collection
        If .SelBookmarks.Count <> 0 Then .SelBookmarks.Remove 0
        ' Append your bookmark to the collection of selected rows
        If Not IsNull(.Bookmark) Then .SelBookmarks.Add .Bookmark
    End With
End Sub

Private Sub Form_Load()
Dim colX As Variant

    Set rstX = New ADODB.Recordset
    rstX.CursorLocation = adUseClient
    rstX.Open "Select * from Employees", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Projets VB\NWIND.MDB;Persist Security Info=False", adOpenStatic, adLockReadOnly
    Set DataGrid1.DataSource = rstX
    DataGrid1.Refresh
    For Each colX In DataGrid1.Columns
        colX.Locked = True
    Next
End Sub

0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

656 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