ass
  • ass
  • Newbie Topic Starter
2014-02-03T16:27:46Z
Hello, you can perform an action when pressing enter in the selected row?

I'm using the event:

grid_KeyDown (KeyCode As Integer, Shift As Integer, bDoDefault As Boolean)

with the following code:

ElseIf KeyCode = 13 Then 'ENTER KEYPRESS

but it moves the focus to the next field ...
KGunder
2014-02-03T16:31:33Z
Has you set bDoDefault to False ??
ass
  • ass
  • Newbie Topic Starter
2014-02-03T20:05:07Z
I could not make it work, follows the code I'm using:

Private Sub grid_KeyDown(KeyCode As Integer, Shift As Integer, bDoDefault As Boolean)
bDoDefault = False
If KeyCode = 107 Then
Me.txFiltro.SetFocus
Me.txFiltro.SelStart = Me.txFiltro.SelLength + 1
ElseIf KeyCode = 109 Then
Me.txFiltro.SetFocus
If Len(Me.txFiltro.Text & "") > 0 Then
Me.txFiltro.Text = ""
End If
ElseIf KeyCode = 13 Then
MsgBox "enter"
End If
Igor/10Tec
2014-02-04T07:37:22Z
Guys, in MS Access you cannot control whether the ENTER key moves the input focus to the next control or not from iGrid. It's a general MS Access setting for all forms. Google "ms access enter key behavior" to find out more.

Here is one of the numerous answers for Access 2007:
http://answers.microsoft.com/en-us/office/forum/office_2007-access/access-2007-behavior-of-enter-key/769944f9-36e3-44c2-a1af-d0efe404940b?msgId=12ad99b1-a4f9-4d2c-a5e1-2a8562a1423d 

Quote:

Click the big Office button, then Access Options.

Click Advanced.

In the Editing section, you'll find "Move after enter". You can choose between "Don't move", "Next field" and "Next record". Don't forget to click OK after setting the option.



However, you also need to prohibit editing in iGrid when ENTER is pressed - but KGunder's suggestion will not work. The fact is that editing on ENTER is started after the KeyPress event but not KeyDown. Thus, you need to use iGrid's KeyPress event for that. You should set its CharCode parameter to 0 if it equals 13 (ENTER).

Note that you can also control whether editing can be started for a specific cell regardless of any key strokes or mouse actions using the RequestEdit event.