key down to cycle records

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have one combo box whose value populates my subform
based on a query. Is there a way to have either the
arrow keys or scroll mouse click update the value of the
combo box to the next value (plus or minus one) and then
refresh the subform?
Can you recommend a good intermediate book on VB or
Access programming?
 
David,

I don't really know about the mouse wheel, but I'll have a go at some
"air code" for up and down arrow keys...

**********
Private Sub YourCombo_KeyDown(KeyCode As Integer, Shift As Integer)

Dim rst as DAO.Recordset
Dim strCrit As String
If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then
Set rst = CurrentDb.OpenRecordset("sorted query that is the
combo's rowsource")
strCrit = "BoundField=" & Me.YourCombo
rst.FindFirst strCrit
Select Case KeyCode
Case vbKeyDown
rst.MoveNext
Case vbKeyUp
rst.MovePrevious
End Select
KeyCode = 0
Me.YourCombo = rst!BoundField
Me.YourSubform.Requery
rst.Close
Set rst = Nothing
End If
End Sub

**********

- Steve Schapel, Microsoft Access MVP
 
Back
Top