473,397 Members | 1,972 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,397 software developers and data experts.

GrayJay's code for dynamic combo box that sub-selects the sourcebased on characters entered

In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until the
one you want can be found. I'm sure you could hack this around to suit your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box I
use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to manually
redisplay the drop down box. If I enter another key, the drop down box
closes up. So essentially it works reasonably but only for 1 character,
although you do have to press the "down arrow" an extra time.

Suggestions?

Bob
Nov 13 '05 #1
9 3375
Bob Alston wrote:
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until the
one you want can be found. I'm sure you could hack this around to suit your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box I
use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to manually
redisplay the drop down box. If I enter another key, the drop down box
closes up. So essentially it works reasonably but only for 1 character,
although you do have to press the "down arrow" an extra time.

Suggestions?

Bob


Yes. Create a global variable/field and use the KeyDown for the combo
to concatenate the values then requery or give the combo a new
rowsource. You'd set the value to Null or "" on the GotFocus event of
the control.

BTW, you could enter something like
Me.ComboBox.DropDown = True
to force the combo to drop.
Nov 13 '05 #2
Salad wrote:
Bob Alston wrote:
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until
the
one you want can be found. I'm sure you could hack this around to suit
your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box
I use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to
manually redisplay the drop down box. If I enter another key, the
drop down box closes up. So essentially it works reasonably but only
for 1 character, although you do have to press the "down arrow" an
extra time.

Suggestions?

Bob

Yes. Create a global variable/field and use the KeyDown for the combo
to concatenate the values then requery or give the combo a new
rowsource. You'd set the value to Null or "" on the GotFocus event of
the control.

BTW, you could enter something like
Me.ComboBox.DropDown = True
to force the combo to drop.

Unfortunately the syntax
Me.ComboBox.DropDown = True
is not correct.
Also tried code to obtain an object referenct to the combobox and set
the property but that failed also.
Anyone know the proper syntax/reference???
Bob
Nov 13 '05 #3
Bob Alston wrote:
Unfortunately the syntax
Me.ComboBox.DropDown = True
is not correct.
It's just simply Me.ComboBox.DropDown.

When you're coding, look at the intellisense for VBA, it's very helpful.

For example, after you type Me and then a dot, a picklist of a number of
things, including the combobox name appears. Press the tab key when the
VBA picklist highlights the control name (combobox name) and the
intellisense will complete it. After that, key in a dot and another
picklist, specific for the controltype that follows Me. (in this case, a
combobox) appears. When you see a hand pointing to a paper, that means
you're working with a property which requires = True/false or some
value. When it's a little tilted green box with "streak marks" to the
left, it's an executable sort of thing that may not need to be set = to
anything, though it might require parameters afterward.

In your case, "dropdown" is an executable that requires no parameters.

Also tried code to obtain an object referenct to the combobox and set
the property but that failed also.


Did you understand what Salad was suggesting? Maybe he can expand on it
for you?

BTW it's no big shame to admit you don't understand what some folks
write, we all have to learn somewhere. I was asking questions here in
the late 90s that I sometimes see in Google searches and I knew NOTHING.

8)
--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #4
Hi Bob,

Bob Alston <tu****************@cox.net> wrote:
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until the
one you want can be found. I'm sure you could hack this around to suit your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box I
use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to manually
redisplay the drop down box. If I enter another key, the drop down box
closes up. So essentially it works reasonably but only for 1 character,
although you do have to press the "down arrow" an extra time.

Suggestions?

Bob


I'm not sure if a combo box can do what you are trying to do, though
there may be someone around here who will correct me.

The method I gave in my original post worked for me. It used a simple
form with an unbound text box in the header and the detail consisted of
the records which matched it.

I'm sure this method could be used in your app, perhaps with a dbl-click
on the appropriate record to open another form with the full client
info.

BTW this does not take spaces into account, I haven't figured this yet.
--
»«»«»« Graham »«»«»«
Nov 13 '05 #5
Bob Alston wrote:
Salad wrote:
Bob Alston wrote:
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced
until the
one you want can be found. I'm sure you could hack this around to
suit your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo
box I use for client selection, by allowing the user to start typing
the client's last name - the list in the combo box should be
repainted to show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to
manually redisplay the drop down box. If I enter another key, the
drop down box closes up. So essentially it works reasonably but only
for 1 character, although you do have to press the "down arrow" an
extra time.

Suggestions?

Bob


Yes. Create a global variable/field and use the KeyDown for the combo
to concatenate the values then requery or give the combo a new
rowsource. You'd set the value to Null or "" on the GotFocus event of
the control.

BTW, you could enter something like
Me.ComboBox.DropDown = True
to force the combo to drop.


Unfortunately the syntax
Me.ComboBox.DropDown = True
is not correct.
Also tried code to obtain an object referenct to the combobox and set
the property but that failed also.
Anyone know the proper syntax/reference???
Bob


There was someone that asked a very similar question to yours on Nov 11,
2004. The subject line is "Dynamic combo box - limit selection based on
user entry" See if my reply in that thread provides more info. It may
be in your newsreaders header list, otherwise find it at
http://www.groups.google.com

I see that I used the wrong syntax for the .DropDown but that has been
addressed very well. Sometimes it may be best to highlight a method or
property (ex: DropDown), while in the code window, and press F1.

Nov 13 '05 #6
Ken Getz has a procedure to do what you want to do using a textbox and a
listbox in the Access Developer's Handbook. It works extremely well! I have
used it numerous times.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Bob Alston" <tu****************@cox.net> wrote in message
news:dDcod.58567$_g6.51785@okepread03...
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until the
one you want can be found. I'm sure you could hack this around to suit your app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box I
use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to manually
redisplay the drop down box. If I enter another key, the drop down box
closes up. So essentially it works reasonably but only for 1 character,
although you do have to press the "down arrow" an extra time.

Suggestions?

Bob

Nov 13 '05 #7
Tim Marshall wrote:
BTW it's no big shame to admit you don't understand what some folks
write, we all have to learn somewhere. I was asking questions here in
the late 90s that I sometimes see in Google searches and I knew NOTHING.


Fools and wise make mistakes alike, only fools hide them.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #8
Tim Marshall wrote:
Bob Alston wrote:
Unfortunately the syntax
Me.ComboBox.DropDown = True
is not correct.

It's just simply Me.ComboBox.DropDown.

When you're coding, look at the intellisense for VBA, it's very helpful.

For example, after you type Me and then a dot, a picklist of a number of
things, including the combobox name appears. Press the tab key when the
VBA picklist highlights the control name (combobox name) and the
intellisense will complete it. After that, key in a dot and another
picklist, specific for the controltype that follows Me. (in this case, a
combobox) appears. When you see a hand pointing to a paper, that means
you're working with a property which requires = True/false or some
value. When it's a little tilted green box with "streak marks" to the
left, it's an executable sort of thing that may not need to be set = to
anything, though it might require parameters afterward.

In your case, "dropdown" is an executable that requires no parameters.

Also tried code to obtain an object referenct to the combobox and set
the property but that failed also.

Did you understand what Salad was suggesting? Maybe he can expand on it
for you?

BTW it's no big shame to admit you don't understand what some folks
write, we all have to learn somewhere. I was asking questions here in
the late 90s that I sometimes see in Google searches and I knew NOTHING.

8)

Thank you. I had misunderstood the object type. I thought it was a
property that needed a value.

Also thanks for clarifying intellisense for VBA. I use it and have
found it helpful. I just didn't understand the nuances. Thanks.

Bob
Nov 13 '05 #9
PC Datasheet wrote:
Ken Getz has a procedure to do what you want to do using a textbox and a
listbox in the Access Developer's Handbook. It works extremely well! I have
used it numerous times.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Bob Alston" <tu****************@cox.net> wrote in message
news:dDcod.58567$_g6.51785@okepread03...
In 2002, "GrayJay" posted the following code:

I did this in a jazz record catalogue to find composers -

On a form "frmComposers"
Create a text box - txtFindComposer, and add the following sub

Private Sub txtFindComposer_Change()
Requery
Me![txtFindComposer].SetFocus
SendKeys "{F2}", True
End Sub

The form's Record Source is:

SELECT tblTunes.Composer,
InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1) AS
NamePosition, tblTunes.TuneID, tblTunes.TuneTitle, tblTunes.TuneNotes
FROM tblTunes
WHERE
(((InStr(1,[composer],[Forms]![frmComposers]![txtFindComposer],1))<>0))
ORDER BY tblTunes.Composer;

Now adding one letter at a time the list of composers is reduced until the
one you want can be found. I'm sure you could hack this around to suit


your
app. I don't know how well it would work with 132,000 records though.

HTH

"Mike" <mi**@abchansen.ru> wrote:

**********************************
Recently I have been trying to do the same thing. Enhance a combo box I
use for client selection, by allowing the user to start typing the
client's last name - the list in the combo box should be repainted to
show only names that equal the letters typed so far.
I can get it to work for a single keypress. However I have to manually
redisplay the drop down box. If I enter another key, the drop down box
closes up. So essentially it works reasonably but only for 1 character,
although you do have to press the "down arrow" an extra time.

Suggestions?

Bob


I bought both the 2002 "Access Developer's Handbook" series you
mentioned. Can you point me to where it is in the book?

Bob
Nov 13 '05 #10

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

Similar topics

4
by: Tom Louchbaum | last post by:
Is there a VBA code that will cuase all reports withihn the open database to close? Thanks,
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.