'----------------------------------
Sub txtDefectCode_OnKeyDown
'If cursor down or page down, set focus to cboDefectCauses
'so that further keypresses are processed there
'(so further cursor keystrokes will scroll the combo)
If Window.Event.Keycode = 40 or Window.Event.Keycode = 34 Then
txtDefectCode.Value = ""
cboDefectCauses.Focus
End If
End Sub
'----------------------------------
Sub txtDefectCode_OnKeyUp
'If Backspace key hit, reset gsSaveKeyedDefectCode to value of text
'and re-search the combo box
If Window.Event.Keycode = 8 Then
gsSaveKeyedDefectCode = txtDefectCode.Value
If gsSaveKeyedDefectCode <> "" Then
PositionDefectCausesToKeyedCode
Else
'They have "emptied" the text box, so position combo to nothing selected
cboDefectCauses.SelectedIndex = 0
cboDefectCauses.SelectedIndex = -1
End If
End If
End Sub
'----------------------------------
Sub txtDefectCode_OnKeypress
Dim sCharacter
If Window.Event.Keycode = 13 then 'If hit enter, go to combo (if you have found it)
gbDefectsEntered = True
gsSaveKeyedDefectCode = ""
'If selected index <> -1 then found the one they want
If cboDefectCauses.SelectedIndex = -1 Then
cboDefectCauses.Focus
Else
txtNumDefects.Focus
End If
'clear text regardless
txtDefectCode.Value = ""
Else
sCharacter = Chr(Window.Event.Keycode)
'Send what has previously been keyed plus this character to the search
gsSaveKeyedDefectCode = gsSaveKeyedDefectCode & sCharacter
PositionDefectCausesToKeyedCode
End If
End Sub
'=======================================================================
Sub PositionDefectCausesToKeyedCode
Dim nInt
If cboDefectCauses.SelectedIndex = -1 Then
cboDefectCauses.SelectedIndex = 0
End If
For nInt = 0 to (cboDefectCauses.Options.length - 1)
'If keyed code > one we're on, bump up the one we're on to the next one
'and check again
If nInt <= (cboDefectCauses.Options.length - 1) Then
If CInt(gsSaveKeyedDefectCode) <= CInt(cboDefectCauses.Options(nInt).Value) Then
cboDefectCauses.SelectedIndex = nInt
Exit For
End If
Else
cboDefectCauses.SelectedIndex = (cboDefectCauses.Options.length - 1)
Exit For
End If
Next
End Sub