Solved No dropdown (1 Viewer)

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
Search as I may, I cannot find a satisfactory answer to the apparently common problem of dropdown lists not dropping down on command.
The simple form attached is a case in point. None of my code variations, nor property adjustments, cause the list to appear.
In the attached sample I have commented out the all but the last unsuccessful attempts.
The "txtHolder" text box is only for testing purposes. The operative form does not have this text box.
This form is activated if a data change is detected.
Once a selection is made, the form passes the result to a history file and then closes.
 

Attachments

  • Database1.zip
    23.4 KB · Views: 74

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:11
Joined
Oct 29, 2018
Messages
21,473
The simple form attached is a case in point. None of my code variations, nor property adjustments, cause the list to appear.
I don't understand the intent. Since you commented out all the dropdown code, I am not sure what we're supposed to expect to happen nor what to do to initiate something to happen. Can you please provide a step-by-step guide to help us understand the problem?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:11
Joined
Oct 29, 2018
Messages
21,473
I don't understand the intent. Since you commented out all the dropdown code, I am not sure what we're supposed to expect to happen nor what to do to initiate something to happen. Can you please provide a step-by-step guide to help us understand the problem?
Well, I gave it a shot. See if this is what you meant.
 

Attachments

  • Database1.zip
    26.8 KB · Views: 70

June7

AWF VIP
Local time
Yesterday, 22:11
Joined
Mar 9, 2014
Messages
5,471
You want the list to drop when form opens? I set a breakpoint on the Dropdown line in Load event and stepped through. Interesting. The drop list appears before the form displays. Then when form completes loading the list is collapsed.

I see DB has solved it with a Timer event.
 

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
I don't understand the intent. Since you commented out all the dropdown code, I am not sure what we're supposed to expect to happen nor what to do to initiate something to happen. Can you please provide a step-by-step guide to help us understand the problem?
Firstly, you obviously didn't read my intro or look at the code included.
I stated that I had commented out "all but the last" unsuccessful attempts.
The following was not commented out.
"Private Sub cboReason_GotFocus()
Me.cboReason.Dropdown
End Sub"
Given there is one combobox on the form I'm not sure what "steps" you require to be detailed. Click on the arrow and select something!
I also described, in as much detail as I considered appropriate, what the form does and how it is activated.
Secondly, I am not looking for a "work around" but an explanation of why the dropdown list does not appear when commanded.

June7 has, at least, detected a possible problem in that the list does, in fact, dropdown albeit before the form opens and then disappears.
Thank you June7. I will work on that. It would seem it has something to do with the form's event timing and hierarchy.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:11
Joined
Oct 29, 2018
Messages
21,473
Firstly, you obviously didn't read my intro or look at the code included.
I stated that I had commented out "all but the last" unsuccessful attempts.
The following was not commented out.
"Private Sub cboReason_GotFocus()
Me.cboReason.Dropdown
End Sub"
Given there is one combobox on the form I'm not sure what "steps" you require to be detailed. Click on the arrow and select something!
I also described, in as much detail as I considered appropriate, what the form does and how it is activated.
Secondly, I am not looking for a "work around" but an explanation of why the dropdown list does not appear when commanded.

June7 has, at least, detected a possible problem in that the list does, in fact, dropdown albeit before the form opens and then disappears.
Thank you June7. I will work on that. It would seem it has something to do with the form's event timing and hierarchy.
Well, did you try the demo file I posted afterwards? Just curious...

Edit: After reading your response to June7, I would be interested to learn the solution you come up with.
 

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
Well, did you try the demo file I posted afterwards? Just curious...

Edit: After reading your response to June7, I would be interested to learn the solution you come up with.
Yes. I did try your work around. It works, but only after a significant delay between the form opening and the dropdown re-appearing.
I am still working on the event order of the form opening. So far I do not have a solution but will post as soon as I figure it out.
There seems to be a bit more to it than just the event sequence since the actual appearance of the form seems to cancel the dropdown command.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:11
Joined
Oct 29, 2018
Messages
21,473
Yes. I did try your work around. It works, but only after a significant delay between the form opening and the dropdown re-appearing.
I am still working on the event order of the form opening. So far I do not have a solution but will post as soon as I figure it out.
There seems to be a bit more to it than just the event sequence since the actual appearance of the form seems to cancel the dropdown command.
Sorry it took me a while to understand what you meant. Hope you find a good solution. Just curious if the "significant delay" can become tolerable if you change the timer to a much lower interval. (I just used 500 for no particular reason.)
 

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
Sorry it took me a while to understand what you meant. Hope you find a good solution. Just curious if the "significant delay" can become tolerable if you change the timer to a much lower interval. (I just used 500 for no particular reason.)
I am using the default timer delay of 0 and the system is running on a wireless intranet so that slows things down somewhat.
I have come to the conclusion that the dropdown is being cancelled after the current event "end sub". I'm still trying to determine what happens there.
I have skinnied down the form to just the current event. If you add a breakpoint at the first line and step through, you will see what happens.
 

Attachments

  • Database1.zip
    26.2 KB · Views: 67

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
Sorry it took me a while to understand what you meant. Hope you find a good solution. Just curious if the "significant delay" can become tolerable if you change the timer to a much lower interval. (I just used 500 for no particular reason.)
I found this work around in a 2014 post on this forum.
The general consensus then was "It's a quirk and there's no real answer"
It works with the caveat that the dropdown only stays until you do something, anything, then it disappears.
The main difference is there is no delay in the dropdown appearing.
The fact that the dropdown vanishes does not affect my application since the form closes "afterupdate" anyway.

June7 you were much involved in that earlier post.

Code:
Option Compare Database
Option Explicit

Private Sub Form_Current()
    Me.SetFocus  'Probably not required, just a part of my testing.
    Me.btnReason.Caption = "Please select the reason for this" & vbCrLf & "change from the list below."
    Me.cboReason = ""
    Me.cboReason.SetFocus
End Sub

Private Sub cboReason_GotFocus()
    Me.TimerInterval = 1
End Sub

Private Sub Form_Timer()
    Me.TimerInterval = 0
    me.cboReason.Dropdown
End Sub

I thank you both for your input.
John
 

isladogs

MVP / VIP
Local time
Today, 07:11
Joined
Jan 14, 2017
Messages
18,221
If you want the dropdown to remain even after changing focus or entering a value, why not use a listbox instead?
 

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
If you want the dropdown to remain even after changing focus or entering a value, why not use a listbox instead?
I had given that some thought but the form closes immediately after a selection is made so it was of no consequence.
 

isladogs

MVP / VIP
Local time
Today, 07:11
Joined
Jan 14, 2017
Messages
18,221
Even so, by using a listbox you wouldn't need to use workaround code like that above to get the combo to dropdown when the form loads
 

June7

AWF VIP
Local time
Yesterday, 22:11
Joined
Mar 9, 2014
Messages
5,471
Depends on which behavior is more convenient. Listbox does not have AutoExpand property. Can select row by typing first letter. If multiple rows start same, keep typing same letter until reaching desired row or use up/down arrows. Or go to mouse and click, which I try to avoid requiring when designing data entry forms.
 
Last edited:

John Sh

Member
Local time
Today, 16:11
Joined
Feb 8, 2021
Messages
410
Even so, by using a listbox you wouldn't need to use workaround code like that above to get the combo to dropdown when the form loads
I have rebuilt the form using a listbox, as you suggested.
The end result is much cleaner than before while the functionality is identical.
With the addition of another column in the table I was also able to sort the data in a more logical order.
Thank you for the suggestion and your persistence.
John
 

Attachments

  • Database1.zip
    41.6 KB · Views: 66

isladogs

MVP / VIP
Local time
Today, 07:11
Joined
Jan 14, 2017
Messages
18,221
Sometimes it just needs someone else to suggest another approach. :cool:
Glad to have helped indirectly....
 

Users who are viewing this thread

Top Bottom