Combo Box

blueboron

Registered User.
Local time
Today, 10:57
Joined
Aug 2, 2005
Messages
18
Hi,

I have a Combo Box with the following choices

Sales
Resale
Overheads

For speed (when the combo box has the focus) I want to press 1 on the number pad and sales appear in the combo box - I have no idea how to acheive this:confused: - I can do it if I put the 1 in front of the Sales in the table - but this is not what I require - I just want the choice Sales to appear.

Any help would be greatly appreciated.

Thanks

BB
 
No offense, but why do you want to do this? The users will know the CBO contains Sales/Resale/Overheads. Set the property "Auto Expand" to "Yes". Then when the users type "S", "Sales" will automatically be filled -- as you illustrated when you put a "1" in front of Sales. If the numbers 1-3 are not used elsewhere for any reason, then it is unnecessary code.
 
Thanks for your reply,

It is for speed, also it will assist me with other bits of the project and I would like it.

Can this be done in Access?

If so I really would appreciate a clue or 2.

Thanks

BB
 
I understand the need for speed, and yes you can do this. I have a form with a date field, and I wanted to use the + and - keys to increment or decrement the date. Your requirement seems similar.

I used the On Key Down and On Key Up events to detect when the + or - keys were pressed - you should be able to do the same for the number pad keys, although the number pad keys may require using the On Key Press event due to different encoding. Play around with these events, and just debug.print the incoming values to see which one you want to trap.

Here's what I did:

Private Sub txtDated_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_txtDated_KeyDown

If KeyCode = 189 Or KeyCode = 187 Then
m_lastDated = Me.txtDated.Value
End If

Exit_txtDated_KeyDown:
Exit Sub

Err_txtDated_KeyDown:
Global_Error m_moduleName, "txtDated_KeyDown", Err.Description, Err.Number
Resume Exit_txtDated_KeyDown

End Sub

Private Sub txtDated_KeyUp(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_txtDated_KeyUp

Dim checkDate As Date
If KeyCode = 189 Then
checkDate = CDate(m_lastDated)
checkDate = checkDate - 1
Me.txtDated.Value = Format(checkDate, "mm/dd/yyyy")
ElseIf KeyCode = 187 Then
checkDate = CDate(m_lastDated)
checkDate = checkDate + 1
Me.txtDated.Value = Format(checkDate, "mm/dd/yyyy")
End If

Exit_txtDated_KeyUp:
Exit Sub

Err_txtDated_KeyUp:
Global_Error m_moduleName, "txtDated_KeyUp", Err.Description, Err.Number
Resume Exit_txtDated_KeyUp

End Sub
 

Users who are viewing this thread

Back
Top Bottom