Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228

    Listbox "On Key Down" Property Forces Exit

    When I enter a listbox and I hit up or down, I would like it to cycle through options of the listbox without leaving the control. Each time I hit up or down it leaves, and it seems as though that I cannot get it to focus back on the original listbox.

    If possible I would like it to not leave the listbox in general. I have tried .setfocus on other controls and then .setfocus back on the original, that does not work. I have also tried DoCmd.GoToControl (ctrl).

    the "On Key Down" on each points to this function...

    Code:
    Function newkeypress(Keycode As Integer, Shift As Integer)
    Dim thectrl As String, ctrl As Control, count As Integer, frm As Form
    
    If Keycode = 40 Then
    
        thectrl = Screen.ActiveControl.Name
        Set frm = Forms("Warranty Return Addition")
        Set ctrl = frm.Controls(thectrl)
        count = ctrl.ListCount
        
        With ctrl
            If ctrl.Value = "" Then
                ctrl = .ItemData(0)
            ElseIf .Value = count Then
                ctrl = .ItemData(0)
            Else
                ctrl = .ItemData(.Value)
            End If
            DoCmd.GoToControl ("txtdatecode")
            DoCmd.GoToControl (.Name)
        End With
    Else
        Exit Function
    End If
    
    End Function


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I cannot replicate the issue. Pressing arrow or page keys does not exit listbox for me.

    Why do you have this procedure? What is it intended to accomplish?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    This is meant to occur when the list is not technically "open". When you tab into the listbox and hit the down/up arrow without manually clicking open the actual list.

    I want to be able to navigate the screen without the mouse.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    is this a combobox?

    .setfocus
    .dropdown

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Same with combobox - cannot replicate issue. Cursor keys do not cause box to lose focus.

    ItsMe has a good question. What you describe sounds more like combobox behavior and need code, like:

    Private Sub cbxMethod_Enter()
    Me.cbxMethod.Dropdown
    End Sub

    Also, might make sure the AutoExpand property is set to Yes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Quote Originally Posted by ItsMe View Post
    is this a combobox?

    .setfocus
    .dropdown
    It is a listbox

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    How can a listbox not be 'open'? A listbox does not have a dropdown list to be opened. That is a combobox. A listbox list is always displayed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Excuse me, my mistake, it is a combobox.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Does the suggested code do what you want?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    It is similar to what I was looking for. I was probably over thinking the issue. I was going for a solution that did not technically open the drop down menu. This will work great though. Thanks for the assistance, again sorry for the combobox/listbox mistake.

  11. #11
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    Is there anyway to adjust which value is the default high-lighted when you use .dropdown?

    For instance, if you were to hit the down arrow it would scroll down, thus starting from the top (first value).

    Or if you hit the up arrow it would scroll up, thus starting from the last entry.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The AutoExpand property will help fill in the combobox value. My people still want to see the list.

    There is a DefaultValue property but that will work only for new record.

    For existing record, if data already in the field it should show as highlighted item in list.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    maybe

    .SelText = "TextToSelectFromCombobox"

    untested

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Not finding a .SelText property.

    There are .SelStart and .SelLength but those concern selecting the string in the box, not the list.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    kdbailey is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    228
    I decided to adjust some things to how/when I want them opening. I should be set, thanks for the assitance.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Listbox "On Not In List" Property
    By kdbailey in forum Access
    Replies: 3
    Last Post: 01-03-2014, 11:11 AM
  2. Replies: 7
    Last Post: 11-08-2013, 08:28 PM
  3. Filter Form with "CurrentRecord" property
    By bbrazeau in forum Forms
    Replies: 3
    Last Post: 05-24-2013, 10:16 AM
  4. Replies: 16
    Last Post: 11-01-2011, 01:35 PM
  5. Replies: 11
    Last Post: 11-26-2010, 10:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums