473,883 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combobox dropdown

Gil
Is there a way to tell if a combbox is in dropdown mode.
I tried and if statement combobox.dropdo wn = 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.d ropdown state return true or false i would
tell it to update rowsource when activecontrol.d ropdown = false and to
update field when activecontrol.d ropdown = 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_KeyDo wn(KeyCode As Integer, Shift As Integer)
If IsNull(Me.COMBO BOX1.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.Se tFocus
x = Nz(Me.txtSTNUM1 )
str1 = Me.COMBOBOX1.Te xt
strRow = "SELECT * WHERE COMBO LIKE '" & Str1 &"' & '*' "
Me.COMBOBOX1.Ro wSource = 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_GotFo cus()
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.SetF ocus 'YOU HAVE TO SET FOCUS TO SOMETHING ELSE FIRST
Me.COMBOBOX1.Se tFocus
Call PutCursorAtEnd 'THIS FUNCTION PUTS CURSOR AT END OF CONTROL
Me.COMBOBOX1.Dr opdown
End If
End Sub
if someone has a better idea please let me know
Thanks!

Dec 3 '05 #1
5 10300
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*******@gmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Is there a way to tell if a combbox is in dropdown mode.
I tried and if statement combobox.dropdo wn = 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.d ropdown state return true or false i would
tell it to update rowsource when activecontrol.d ropdown = false and to
update field when activecontrol.d ropdown = 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_KeyDo wn(KeyCode As Integer, Shift As Integer)
If IsNull(Me.COMBO BOX1.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.Se tFocus
x = Nz(Me.txtSTNUM1 )
str1 = Me.COMBOBOX1.Te xt
strRow = "SELECT * WHERE COMBO LIKE '" & Str1 &"' & '*' "
Me.COMBOBOX1.Ro wSource = 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_GotFo cus()
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.SetF ocus 'YOU HAVE TO SET FOCUS TO SOMETHING ELSE FIRST
Me.COMBOBOX1.Se tFocus
Call PutCursorAtEnd 'THIS FUNCTION PUTS CURSOR AT END OF CONTROL
Me.COMBOBOX1.Dr opdown
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*******@gmai l.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
2071
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, when the dropdown is visible and the user clicks anywhere else, the dropdown gets hidden. i am trying to replicate this behavior and have tried using the Leave and LostFocus events. i have had marginal success when my dropdown is visible and i...
7
8549
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 of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
7
23536
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 for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
2
4347
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 how to use this code? please help! http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
1
2318
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 collection, the .text property does not update. Furthermore, you can't easily trap an event to examine the new value if your program assigns it programmatically as opposed to someone typing it in and tabbing away from it. That is, TextChanged does...
0
1788
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 if you click on the DropDown button the control is displayed. If you click anywhere other than the DropDown button the control is removed. This works well. Sequence of events is:
4
2460
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 = -1. If it isn't an mdi child, then there isn't a problem. I have tried setting it to -1 two times. I have tried setting the selecteditem property to -1 and also to nothing. None of it seems to make a difference. Any help will be appreciated.
0
1487
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 combobox is selected via mouse click it draws the dropdown list twice. As I am trapping the enter event, I can see thats is called as well some other ? the style is set to dropdownlist as they must select one from the list I assume I must trap a...
1
2077
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 a listbox.selecteditem. When a different item is selected in the listbox, all the fields are repopulated with the correct data. I have 1 combobox which is acting weird.
0
9943
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9793
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10750
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10419
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7134
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3237
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.