473,416 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

combobox dropdown

Gil
Is there a way to tell if a combbox is in dropdown mode.
I tried and if statement combobox.dropdown = true
but i get an error. dropwndown function doesnt store if its true or
false
what i am trying to do is make an autoscroll combobox. like you have on
html textbox's, but this time you hit enter for a change to be made. i
do this because i dont want to requery every time a single letter is
inputed. it would be too slow. so i make them hit enter when they are
ready to search.
you type something in the combox, hit enter, and the combobox refreshes
itself with the new data. then you can choose an item from the dropdown
but this time when you hit enter again rather then refresh the
combobox rowsource, i want the combobox to finally update and move on.
If i had a activecontrol.dropdown state return true or false i would
tell it to update rowsource when activecontrol.dropdown = false and to
update field when activecontrol.dropdown = true.
But i dont have that so i came up with this longggg way...

heres how i did it:

'WHEN YOU HIT ENTER REFRESH THE ROWSOURCE WITH NEW CRITERIA AND
'SET DROPDOWN VARIABLE TO TRUE

Dim onEnter as boolean ' Lets me know if enter was hit already
Dim onDropDown as Boolean ' Lets me know if the combobox is in dropdown
state
Private Sub COMBOBOX1_KeyDown(KeyCode As Integer, Shift As Integer)
If IsNull(Me.COMBOBOX1.Text) Then Exit Sub
Select Case KeyCode
Case 13 'enter
If onDropDown = False Then
Dim strRow As String
Dim x As Integer
Dim strStr1 As String

onEnter = True
Me.COMBOBOX1.SetFocus
x = Nz(Me.txtSTNUM1)
str1 = Me.COMBOBOX1.Text
strRow = "SELECT * WHERE COMBO LIKE '" & Str1 &"' & '*' "
Me.COMBOBOX1.RowSource = strRow

End If
Case 37, 38, 39, 40, 9 'IF ANY KEY IS HIT OTHER THAN ARROW KEYS AND TAB
THEN
Case Else
If onDropDown = True Then onDropDown = False 'RESET DROPDOWN STATE
End Select
End Sub

'WHEN YOU GET FOCUS RESET DROPDOWN STATE

Private Sub COMBOBOX1_GotFocus()
If onDropDown = True Then onDropDown = False
End Sub

'WHEN YOU HIT ENTER YOUR AUTOMATICALLY LOOSE THE FOCUS SO
'WHEN YOU LOOSE FOCUS DURING DROPDOWN STATE BRING THE FOCUS BACK
Private Sub COMBOBOX1_Exit(Cancel As Integer)
If onEnter Then
onDropDown = True
onEnter = False
Me.TEXTBOX.SetFocus 'YOU HAVE TO SET FOCUS TO SOMETHING ELSE FIRST
Me.COMBOBOX1.SetFocus
Call PutCursorAtEnd 'THIS FUNCTION PUTS CURSOR AT END OF CONTROL
Me.COMBOBOX1.Dropdown
End If
End Sub
if someone has a better idea please let me know
Thanks!

Dec 3 '05 #1
5 10271
Why would you want to recreate a clumsier version of the built-in AutoExpand
feature of Access' Combo Boxes? AutoExpand is set to yes by default, out of
the box. If you've turned it off as a default, open the Property Sheet, and
choose Yes for AutoExpand. It scrolls as you type, without your having to
click Enter. If I understand your post, that is what you wanted to do.

Larry Linson
Microsoft Access MVP

"Gil" <gi*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Is there a way to tell if a combbox is in dropdown mode.
I tried and if statement combobox.dropdown = true
but i get an error. dropwndown function doesnt store if its true or
false
what i am trying to do is make an autoscroll combobox. like you have on
html textbox's, but this time you hit enter for a change to be made. i
do this because i dont want to requery every time a single letter is
inputed. it would be too slow. so i make them hit enter when they are
ready to search.
you type something in the combox, hit enter, and the combobox refreshes
itself with the new data. then you can choose an item from the dropdown
but this time when you hit enter again rather then refresh the
combobox rowsource, i want the combobox to finally update and move on.
If i had a activecontrol.dropdown state return true or false i would
tell it to update rowsource when activecontrol.dropdown = false and to
update field when activecontrol.dropdown = true.
But i dont have that so i came up with this longggg way...

heres how i did it:

'WHEN YOU HIT ENTER REFRESH THE ROWSOURCE WITH NEW CRITERIA AND
'SET DROPDOWN VARIABLE TO TRUE

Dim onEnter as boolean ' Lets me know if enter was hit already
Dim onDropDown as Boolean ' Lets me know if the combobox is in dropdown
state
Private Sub COMBOBOX1_KeyDown(KeyCode As Integer, Shift As Integer)
If IsNull(Me.COMBOBOX1.Text) Then Exit Sub
Select Case KeyCode
Case 13 'enter
If onDropDown = False Then
Dim strRow As String
Dim x As Integer
Dim strStr1 As String

onEnter = True
Me.COMBOBOX1.SetFocus
x = Nz(Me.txtSTNUM1)
str1 = Me.COMBOBOX1.Text
strRow = "SELECT * WHERE COMBO LIKE '" & Str1 &"' & '*' "
Me.COMBOBOX1.RowSource = strRow

End If
Case 37, 38, 39, 40, 9 'IF ANY KEY IS HIT OTHER THAN ARROW KEYS AND TAB
THEN
Case Else
If onDropDown = True Then onDropDown = False 'RESET DROPDOWN STATE
End Select
End Sub

'WHEN YOU GET FOCUS RESET DROPDOWN STATE

Private Sub COMBOBOX1_GotFocus()
If onDropDown = True Then onDropDown = False
End Sub

'WHEN YOU HIT ENTER YOUR AUTOMATICALLY LOOSE THE FOCUS SO
'WHEN YOU LOOSE FOCUS DURING DROPDOWN STATE BRING THE FOCUS BACK
Private Sub COMBOBOX1_Exit(Cancel As Integer)
If onEnter Then
onDropDown = True
onEnter = False
Me.TEXTBOX.SetFocus 'YOU HAVE TO SET FOCUS TO SOMETHING ELSE FIRST
Me.COMBOBOX1.SetFocus
Call PutCursorAtEnd 'THIS FUNCTION PUTS CURSOR AT END OF CONTROL
Me.COMBOBOX1.Dropdown
End If
End Sub
if someone has a better idea please let me know
Thanks!

Dec 3 '05 #2
Gil
Hello,
thanks for the reply.
I am trying to fliter a 500,000 record combobox down to only the
results typed into the combobox. It will speed up the form. Besides
that you are right. I could stick with the default autoexpand.
How would you handle such large data in a single combobox?

Dec 3 '05 #3
YUCK... don't populate the combobox (don't assign a rowsource) until
AFTER you have typed in maybe 5 characters.

Wow. How does the form perform if your have a split front and back
end? I'd imagine that performance would be hideous...

Dec 3 '05 #4
Gil wrote:
Hello,
thanks for the reply.
I am trying to fliter a 500,000 record combobox down to only the
results typed into the combobox. It will speed up the form. Besides
that you are right. I could stick with the default autoexpand.
How would you handle such large data in a single combobox?

You have got to be trolling...or kidding...or something. A 500,000
record combo box? Hahahahaha.

Have you ever heard of a form? 500,000 record combo box? Hahahahaha.
Good one.

Dec 3 '05 #5
"Gil" <gi*******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I am trying to fliter a 500,000 record combobox down to only the
results typed into the combobox. It will speed up the form. Besides
that you are right. I could stick with the default autoexpand.
How would you handle such large data in a single combobox?


I understand your situation. I agree with Piet and Salad that is too much
for a Combo Box -- I can't remember the limit in Row Source, but I don't
remember that it is half-a-million. Do you have any idea of the distribution
of the contents by beginning letter of the alphabet?

You may have to do some filtering, as Piet suggested, before you even load
the Combo Box.

Very likely the users will not be just randomly browsing, so the information
they'll have before searching is important to know in designing a solution.

I once worked on someone else's database application that populated a
continous forms view form with thousands of records, and I really wanted to
change that. But, what I found out was that the users did not use that
screen to select -- they always had a paper file in hand that had a specific
identification code that they typed in to a text box that took them directly
to the record they needed.

If you have to "go brute force", in the Change event, which fires on every
character typed in, you would use VBA code to pick up the value entered so
far, build an SQL statement with a LIKE clause, and replace the Row Source
of the Combo with your new SQL.

Larry Linson
Microsoft Access MVP

Dec 3 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jean | last post by:
hi: i am developing a custom combobox for my company's needs that is made up of a textbox, listbox, button. i am using c#. everything is fine except for one issue. in a normal combobox,...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
7
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
1
by: Norm Katz | last post by:
When you use a bound combobox and you set its dropdown style to "dropdown" that allows you to enter text in the edit box. But if you enter anything other than a value in the current bound items...
0
by: Mike | last post by:
Hi all! I have an OwnerDrawVariable ComboBox in .net. In the ComboBox DropDown event I display another control - works well. In the control's Leave event I remove the control - works well. So...
4
by: Kalvin | last post by:
I have seen this question raised, but I cannot find an answer. I have an MDI app, when I load an child form with a combobox being bound in the load event, it won't allow me to set selectedindex =...
0
by: | last post by:
Hi All. I have a problem with combobox, what I want is when combobox gets focus I need it to show the dropdown list t.This is fine if the user selects the combobox via keystrokes but when the...
1
by: amber | last post by:
I'm having an issue with a combobox that is making no sense to me at all. I have a form with several comboboxes/textboxes. The values in these boxes are based on a datarowview, which is based on...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.