Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DataGrid coledit

Posted on 2004-10-07
1
Medium Priority
?
447 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
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…
Suggested Courses

885 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