Solved

Datagrid Control - Error: The current row is not available

Posted on 2004-04-29
1
1,187 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 125 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
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…

734 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