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

selecting list box entry using a combo box

I have a combo box that lists street numbers. I also have a list box
that lists street numbers and addresses (separately). I want to click
on one of the street numbers and have the first item in the list box
with that street number selected.

Any suggestions will be appreciated.

Deborah

Jul 22 '07 #1
5 2048
Hi Deborah,

Not going to ask you “why use a listbox?”.

But here goes…

Use this air code in you combo box afterupdate event. Assuming both control
in the same form.
Me.ListBoxName.RowSource = “SELECT StreetNumber, Addresses,…..FROM Table1
Where StreetNumber = “ & Me.ComboxName

I’m assuming your StreetNumber Datatype is “Number” as in your table
properties. If they are “Text”, use quotes like… StreetNumber = ‘” & Me.
ComboName & “’”

>dg******@twcny.rr.com wrote:
I have a combo box that lists street numbers. I also have a list box
that lists street numbers and addresses (separately). I want to click
on one of the street numbers and have the first item in the list box
with that street number selected.

Any suggestions will be appreciated.

Deborah
--
Please Rate the posting if helps you

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200707/1

Jul 23 '07 #2
Hi Deborah,
>I want to keep the listbox populated with everyone on the street. I
want the street number combo box to go to the first instance of that
number.
You see, I may have multiple people I want to click on. (This
populates another table.) And by going to the first instance of the
street number, I will not have to scroll through sometimes 100s of
records. I do believe that your solution will repopulate the list box.
Did the code work for you in the cascading combo box? The cascading combo
boxes can do the job of filtering records by the “Street Number” in that list
box.
>I have been trying to use the ItemData property but have not been
successful with the examples I have found on the Internet.
I don’t think it’s practical to use VBA just to filter records on a list box.
Although it can be done by code, it’s basically the same thing using “Do
Loop” or “For Next Loop”, unless…… you say “ I don’t want to use combo boxes.


Show us your code, so that others might be able to help, if they have better
solutions. Remember, nobody can see your database/design except yourself.
>dg******@NOSPAM.twcny.rr.com wrote:
--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com

Jul 24 '07 #3
On Jul 23, 9:16 pm, "AccessVandal via AccessMonster.com" <u18947@uwe>
wrote:
Hi Deborah,
I want to keep the listbox populated with everyone on the street. I
want the street number combo box to go to the first instance of that
number.
You see, I may have multiple people I want to click on. (This
populates another table.) And by going to the first instance of the
street number, I will not have to scroll through sometimes 100s of
records. I do believe that your solution will repopulate the list box.

Did the code work for you in the cascading combo box? The cascading combo
boxes can do the job of filtering records by the "Street Number" in that list
box.
I have been trying to use the ItemData property but have not been
successful with the examples I have found on the Internet.

I don't think it's practical to use VBA just to filter records on a list box.
Although it can be done by code, it's basically the same thing using "Do
Loop" or "For Next Loop", unless...... you say " I don't want to use combo boxes.
"

Show us your code, so that others might be able to help, if they have better
solutions. Remember, nobody can see your database/design except yourself.
dgard...@NOSPAM.twcny.rr.com wrote:

--
Please Rate the posting if helps you

Message posted viahttp://www.accessmonster.com
I think I have it.

Dim lngListNo As Long

lngListNo = Me.cboStNo.ListIndex
Me.lstResidents.Selected(lngListNo) = True

If there are 3 residents at 123 Main Street, 123 is listed 3 times in
cboStNo. Not very elegant, but this is working for me. I'll work on
the niceties later.

Thanks for all your help.

Deborah

Jul 24 '07 #4

This does exactly what I want. I found the code at www.lebans.com and
modified it slightly to work with my app.

Dim lngListNo As Long

lngListNo = Me.cboStNo.ListIndex

' NumRows is the number of completely visible rows in the ListBox
Const NumRows = 7
' Row we want displayed in middle of ListBox.
Dim intDesiredRow As Integer
intDesiredRow = lngListNo
' ListBox must have the Focus
Me.lstResidents.SetFocus
' Force ListBox to start from the top
Me.lstResidents.ListIndex = 1

' Force the Scroll offset we desire
Me.lstResidents.ListIndex = intDesiredRow
' Now select the row without further scrolling
Me.lstResidents.ListIndex = intDesiredRow
Jul 25 '07 #5
Hi Deborah,

I hope the code works for you.

The logic of your code selects only the first row of the list box or the last
row.
>dg******@NOSPAM.twcny.rr.com wrote:
This does exactly what I want. I found the code at www.lebans.com and
modified it slightly to work with my app.

Dim lngListNo As Long

lngListNo = Me.cboStNo.ListIndex

' NumRows is the number of completely visible rows in the ListBox
Const NumRows = 7
' Row we want displayed in middle of ListBox.
Dim intDesiredRow As Integer

intDesiredRow = lngListNo
' ListBox must have the Focus
Me.lstResidents.SetFocus
' Force ListBox to start from the top
Me.lstResidents.ListIndex = 1

' Force the Scroll offset we desire
Me.lstResidents.ListIndex = intDesiredRow
' Now select the row without further scrolling
Me.lstResidents.ListIndex = intDesiredRow
--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com

Jul 25 '07 #6

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

Similar topics

3
by: news.bellatlantic.net | last post by:
I have a fundraising database for an organization. Donations come in from current members anad are found by using a combo box. If the member is found, the After Update macro switches to another...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
1
by: Nathan Sokalski | last post by:
When testing a form of mine which uses RequiredFieldValidators that have the Display property set to "Dynamic" the ErrorMessage property is automatically removed when an entry is completely typed...
0
by: Kovax | last post by:
I am building a database for our HR dept. I have a combo box that allows the user to select an employee name (this is completed) then a second combo box that allows the user to select a report...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I have to load 30,000 unique names into a combox. Filling a dataTable takes only a few milliseconds. But populating the combobox and displaying the list takes several seconds - way...
4
by: access baby | last post by:
i would like to use combobox or list box in a form for data entry do i have to have a table with value in it and the combobox or list box should look in to that table or i type in the values....
2
by: jw01 | last post by:
I have a form in which there is one combo box and three text boxes: Combo Box: -> Item A -> Item B -> Item C TextBox1: TextBox2: ...
1
by: Jason Northampton | last post by:
Hello This is the first time I've used a discusion forum and up until now I have managed to use and or modify VB code from the various sites on the web, until now! This is a simple problem and I...
30
ADezii
by: ADezii | last post by:
This weeks Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
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?
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
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
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,...
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...
0
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 projectplanning, coding, testing,...

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.