Microsoft Access Drop Down List

390 pts.
Tags:
ComboBox
Microsoft Access
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
ASKED: February 26, 2009  9:30 PM
UPDATED: March 2, 2009  7:20 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following