472,331 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 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 1977
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.