390 pts.
 Microsoft Access Drop Down List
Hi, I have combo boxes in Microsoft Access where if the user starts typing the drop down list expands. Now if they use the keyboard to select the item, Access moves to the next control and the list is brought back up, but if they use the mouse then the list stays down. I was wondering if there was a way to make the list go back up after_update? Another option I could use is after_update docmd.gotocontrol "ControlName", if I use this is there a way to tell Access to just move to the next control on the tab so I don't have to specify the name of the control? Thanks for your help, Dustin

Software/Hardware used:
ASKED: February 26, 2009  9:30 PM
UPDATED: March 2, 2009  7:20 PM

Answer Wiki:
I thought I would post the following code, that works in Access and allows you to after update goto the next control in the tab order so you don't have to use the docmd.gotocontrol and put in the name of the control. Public Sub MoveFocusToNextControl(xfrmFormName As Form, xctlCurrentControl As Control, _ xblnOnlyTabStopYes As Boolean) ' *** THIS SUBROUTINE MOVES THE FOCUS TO THE NEXT CONTROL IN THE TAB ORDER. ' *** IF xblnOnlyTabStopYes IS TRUE, THEN THE NEXT CONTROL MUST HAVE A TAB ' *** STOP VALUE OF "TRUE" AND MUST BE VISIBLE AND MUST BE ENABLED, ELSE ' *** THE SUBROUTINE GOES TO THE NEXT CONTROL. ' *** NOTE: THIS SUBROUTINE WILL NOT "CYCLE BACK" TO TAB INDEX OF 0, SO ' *** DO NOT USE THIS SUBROUTINE IF THERE IS NO CONTROL CAPABLE OF RECEIVING THE ' *** FOCUS IN THE TAB ORDER SEQUENCE AFTER THE CURRENT CONTROL!!!!! ' Ken Snell - May 26, 2005 Dim xctl As Control Dim lngTab As Long, lngNewTab As Long On Error Resume Next ' Move focus to the next control in the tab order (if that control has a Tab Stop ' property of True) lngTab = xctlCurrentControl.TabIndex + 1 MyLoopLabel: For Each xctl In xfrmFormName.Controls lngNewTab = xctl.TabIndex ' An error will occur if the control does not have a TabIndex property; ' skip over those controls. If Err.Number = 0 Then If lngNewTab = lngTab Then If (xctl.TabStop = True Or xblnOnlyTabStopYes = False) And _ xctl.Visible = True And xctl.Enabled = True Then xctl.SetFocus Exit For Else lngTab = lngTab + 1 GoTo MyLoopLabel End If End If Else Err.Clear End If Next xctl Set xctl = Nothing Err.Clear End Sub Dustin
Last Wiki Answer Submitted:  March 2, 2009  7:20 pm  by  RoadDust   390 pts.
All Answer Wiki Contributors:  RoadDust   390 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _