|
-
Apr 27th, 2000, 12:04 AM
#1
Thread Starter
Hyperactive Member
In a datagrid, I am using arrow keys, tab, and return to advance to the next or previous record, depending on the conditions.
e.g. in the keypress event
Code:
If KeyAscii = vbKeyTab and DataGrid1.Col = 6 Then
'advance to next record
DataGrid1.Row = DataGrid1.Row + 1
DataGrid1.Col = 2
Exit Sub
End If
and I have similar code for the arrow keys and enter. The problem is that if the user is on the last visible record, the grid will advance but the column value will be 0, as in the cursor will not automatically go to Column 2.
Please help, I need it!
Andrew
-
Apr 27th, 2000, 06:46 AM
#2
Thread Starter
Hyperactive Member
found it myself...
ended up answering my own question here, so for those of you who may be doing a search later and open this thread, here is what I did:
Code:
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If Not IsEmpty(LastRow) Then
DataGrid1.Col = LastCol
DataGrid1.CurrentCellVisible = True
End If
End Sub
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If Not Adodc1.Recordset.EOF Then
If DataGrid1.Col = 6 And (KeyCode = vbKeyTab Or KeyCode = vbKeyReturn) _
Or KeyCode = vbKeyDown then
Adodc1.Recordset.MoveNext
End If
End If
If Not Adodc1.BOF Then
If KeyCode = vbKeyUp Then
Adodc1.Recordset.MovePrevious
End If
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|