Selezione combobox con eveto Keypress

di eddy1973 il
2 risposte
Buongiorno,
ho predisposto una combobox precedentemente popolata che vorrei utilizzare per popolare una ulteriore combobox utilizzando un evento keypress sfruttando la pressione del tasto enter.
Questo è il codice:
Private Sub cbo_tcamp_KeyPress(KeyAscii As Integer)
Dim i As Integer
If KeyAscii = vbKeyReturn Then
    For i = 0 To Me.cbo_tcamp.ListCount - 1
    	If Me.cbo_tcamp.Selected(i) = True Then
           Form_Main.cbotipo_camp = Me.cbo_tcamp.ItemData(i)
	End If
    Next
DoCmd.Close acForm, Me.Name
end if
End Sub
Quello che vorrei fare a questo punto è utilizzare i tasti up e down ( Chr(38) e Chr(40) ) per scorrere nell'ultima comobox popolata. Questo però non avviene. Forse manca il setfocus, non so.
Come posso fare per risolvere questo problema?
Grazie.

2 Risposte

  • Ho risolto con il setfocus sulla form e sulla combobox:
    Private Sub cbo_tcamp_KeyPress(KeyAscii As Integer)
    Dim i As Integer
    If KeyAscii = vbKeyReturn Then
        For i = 0 To Me.cbo_tcamp.ListCount - 1
        	If Me.cbo_tcamp.Selected(i) = True Then
               Form_Main.cbotipo_camp = Me.cbo_tcamp.ItemData(i)
               Form_Main.SetFocus
               Form_Main.cbotipo_camp.SetFocus	
            End If
       Next
    DoCmd.Close acForm, Me.Name
    end if
    End Sub
    In precedenza avevo applicato il setFocus soltanto sulla combo e non funzionava. Avevo omesso quello sulla Form.
Devi accedere o registrarti per scrivere nel forum
2 risposte