Hey there.
I am using MsAccess 2000 and am trying to add some extra usability features to a form so I have been using visual basic for Access.
What I am doing is this: Whenever a dropdown box has focus, I want it to dropdown automatically if the box is empty or if the down arrow key is pressed. I have worked it so that if there is already data in the box, the down arrow key drops the box down but doesn't move the selection down until you press the down arrow key again (prevents selecting another item accidentally on the first key press).
I have the code to do what I need but instead of adding a bigger section of the code to all the keydown properties, I am making a function that can be called.
(I don't know if 'property' is the right word for keydown)
Anyway, I want to get the sub name (AFP in this example) and pass it to the function farther down.
How do I do that?
The msgbox line was just for troubleshooting.
The code I used above gives me an 'invalid qualifier' error.
I suppose, if I could work some code that runs in the form just checks when a dropdown box object is hit (or a list of names of dropdown boxes), that would require even less duplication of code but I don't know if that's workable without slowing things down.
Thanks in advance.
I am using MsAccess 2000 and am trying to add some extra usability features to a form so I have been using visual basic for Access.
What I am doing is this: Whenever a dropdown box has focus, I want it to dropdown automatically if the box is empty or if the down arrow key is pressed. I have worked it so that if there is already data in the box, the down arrow key drops the box down but doesn't move the selection down until you press the down arrow key again (prevents selecting another item accidentally on the first key press).
I have the code to do what I need but instead of adding a bigger section of the code to all the keydown properties, I am making a function that can be called.
(I don't know if 'property' is the right word for keydown)
Anyway, I want to get the sub name (AFP in this example) and pass it to the function farther down.
How do I do that?
Code:
Private Sub AFP_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 40 Then Call KeyDownOnce(onceflg, AFP)
End Sub
Code:
Public Function KeyDownOnce(onceflg As Integer, SubName As String)
msg = "onceflg= " + Str(onceflg) + " keycode= " + Str(KeyCode) + " subname= " + SubName
result = MsgBox(msg)
If KeyCode = 40 Then
If onceflg = 0 Then
SubName.Dropdown
KeyCode = 0
onceflg = 1
Else
SubName.Dropdown
End If
End If
End Function
The msgbox line was just for troubleshooting.
The code I used above gives me an 'invalid qualifier' error.
I suppose, if I could work some code that runs in the form just checks when a dropdown box object is hit (or a list of names of dropdown boxes), that would require even less duplication of code but I don't know if that's workable without slowing things down.
Thanks in advance.