G
Guest
I combined Allen Browne's roll dates code and Ken Snell's spin button code to
roll between items in a combo box. This works fine (many thanks to both). I
have code in the AfterUpdate event to enable the appropriate conttrols and
set the focus based on the contents of this combo box. If I use the + or -
keys to change the selection the After Update code is ignored and the focus
moves to the next control instead. How can I correct this?
Here are both codes:
Private Sub MileageDescription_KeyPress(KeyAscii As Integer)
Dim lngCboItem
On Error Resume Next
Select Case KeyAscii
Case 43 ' Plus key
KeyAscii = 0
lngCboItem = Me.MileageDescription.ListIndex + 1
If lngCboItem <= Me.MileageDescription.ListCount - 1 Then _
Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
Case 45 ' Minus key
KeyAscii = 0
lngCboItem = Me.MileageDescription.ListIndex - 1
If lngCboItem >= 0 Then Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
End Select
End Sub
Private Sub MileageDescription_AfterUpdate()
On Error GoTo Err_MileageDescription_AfterUpdate
With Me
Select Case .MileageDescription
Case "State Line"
.State.Enabled = True
.State.SetFocus
Case "Fuel"
.Gallons.Enabled = True
.Gallons.SetFocus
.Amount.Enabled = True
Case "Stop"
.StopPurpose.Enabled = True
.StopPurpose.SetFocus
.Location.Enabled = True
.Location.Requery
Case "Trip End"
.Location.SetFocus
.Location.Enabled = True
.Location.Requery
Case "Wrecker"
.State.Enabled = True
.State.SetFocus
End Select
.State_Cover.Visible = Not .State.Enabled
End With
Exit_MileageDescription_AfterUpdate:
Exit Sub
Err_MileageDescription_AfterUpdate:
MsgBox Err.Description
Resume Exit_MileageDescription_AfterUpdate
End Sub
Thanks in advance.
roll between items in a combo box. This works fine (many thanks to both). I
have code in the AfterUpdate event to enable the appropriate conttrols and
set the focus based on the contents of this combo box. If I use the + or -
keys to change the selection the After Update code is ignored and the focus
moves to the next control instead. How can I correct this?
Here are both codes:
Private Sub MileageDescription_KeyPress(KeyAscii As Integer)
Dim lngCboItem
On Error Resume Next
Select Case KeyAscii
Case 43 ' Plus key
KeyAscii = 0
lngCboItem = Me.MileageDescription.ListIndex + 1
If lngCboItem <= Me.MileageDescription.ListCount - 1 Then _
Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
Case 45 ' Minus key
KeyAscii = 0
lngCboItem = Me.MileageDescription.ListIndex - 1
If lngCboItem >= 0 Then Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
Me.MileageDescription.Value =
Me.MileageDescription.ItemData(lngCboItem)
End Select
End Sub
Private Sub MileageDescription_AfterUpdate()
On Error GoTo Err_MileageDescription_AfterUpdate
With Me
Select Case .MileageDescription
Case "State Line"
.State.Enabled = True
.State.SetFocus
Case "Fuel"
.Gallons.Enabled = True
.Gallons.SetFocus
.Amount.Enabled = True
Case "Stop"
.StopPurpose.Enabled = True
.StopPurpose.SetFocus
.Location.Enabled = True
.Location.Requery
Case "Trip End"
.Location.SetFocus
.Location.Enabled = True
.Location.Requery
Case "Wrecker"
.State.Enabled = True
.State.SetFocus
End Select
.State_Cover.Visible = Not .State.Enabled
End With
Exit_MileageDescription_AfterUpdate:
Exit Sub
Err_MileageDescription_AfterUpdate:
MsgBox Err.Description
Resume Exit_MileageDescription_AfterUpdate
End Sub
Thanks in advance.