Solved

allow only one column to edit in msflexgrid

Posted on 2014-09-02
3
224 Views
Last Modified: 2014-09-02
Using the following code in vb6, I have opened all columns for edit

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

End Sub

Open in new window


How do I limit the editing to only to the 7th column in my table

I am using vb6 and msflexgrid
0
Comment
Question by:al4629740
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40299916
Try

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

If .Col <> 6 Then Exit Sub ' This might need to be 7
Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

Open in new window

0
 

Author Comment

by:al4629740
ID: 40300020
6 is right
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40300074
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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…

708 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

12 Experts available now in Live!

Get 1:1 Help Now