Solved

DataGrid coledit

Posted on 2004-10-07
1
420 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

895 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

14 Experts available now in Live!

Get 1:1 Help Now