I am using this code:
This code changes the value in all of the selected "cells" on my form that is in datasheet view based on the key that was pressed. (Yes, I know they are not really cells, but you know what I am talking about). So if the user highlights several "cells" and then types "Y", the value in those "cells" changes to Y.
Does anyone see any way to make this run faster? It is soooo slow right now . . .
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim strUpdate As String
Dim F As Form
Dim rst As DAO.Recordset
Dim iDown As Integer
Dim iAcross As Integer
Dim iTop As Long
Dim iLeft As Long
Dim bValidate As Boolean
Select Case KeyCode
Case vbKeyY
strUpdate = "Y"
Case vbKeyN
strUpdate = "N"
Case vbKeyA
strUpdate = "A"
Case vbKeyS
strUpdate = "S"
Case Else
Exit Sub
End Select
'get selection
Set F = Forms!ManageRules!ManageRulesDatasheet.Form
Set rst = F.RecordsetClone
rst.MoveFirst
rst.Move (F.SelTop - 1)
For iDown = 1 To F.SelHeight
iLeft = F.SelLeft
For iAcross = iLeft - 2 To F.SelWidth + iLeft - 3
If Not iAcross = 0 Then
rst.Edit
rst.Fields(iAcross) = strUpdate
rst.Update
End If
Next iAcross
rst.MoveNext
Next iDown
F.SelWidth = 0
F.Refresh
End Sub
Does anyone see any way to make this run faster? It is soooo slow right now . . .