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
Solved

Datagrid Control - Error: The current row is not available

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

838 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