Solved

DataGrid coledit

Posted on 2004-10-07
1
431 Views
Last Modified: 2012-08-13
Ola,

I want to prevent users from editing Column 0 in my dataGrid.
This is the code I use to prevent it.
Private Sub grdDataGrid_ColEdit(ByVal ColIndex As Integer)
    If ColIndex = 0 Then
        MsgBox "U may not change this column"
        cmdAdd.SetFocus
    End If
End Sub

But I do want to allow them to edit col 0 when they are entering a new record ( editing col 0 of the last row )

How can this be done?
0
Comment
Question by:DaFou
[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 3

Accepted Solution

by:
Noel_Castillo earned 500 total points
ID: 12274657
You may have your own flag that tells you if your in Add mode

'Declare a Flag on the form (on top)
Private OnAddMode As Boolean

'Let you know that you're in Add Mode
Private Sub grdDataGrid_BeforeInsert(Cancel As Integer)
     OnAddMode = True
End Sub

'Make a little adjustment
Private Sub grdDataGrid_ColEdit(ByVal ColIndex As Integer)
    If ColIndex = 0 And Not OnAddMode Then
        MsgBox "U may not change this column"
        cmdAdd.SetFocus
    End If
End Sub

Private Sub grdDataGrid_AfterUpdate()
    OnAddMode = False
End Sub

hope this helps. :)
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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

740 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