473,835 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2089
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.c om
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******@NOSPA M.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, "AccessVand al via AccessMonster.c om" <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.accessmonst er.com
I think I have it.

Dim lngListNo As Long

lngListNo = Me.cboStNo.List Index
Me.lstResidents .Selected(lngLi stNo) = 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.List Index

' 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******@NOSPA M.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.List Index

' 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

intDesiredRo w = lngListNo
' ListBox must have the Focus
Me.lstResident s.SetFocus
' Force ListBox to start from the top
Me.lstResident s.ListIndex = 1

' Force the Scroll offset we desire
Me.lstResident s.ListIndex = intDesiredRow
' Now select the row without further scrolling
Me.lstResident s.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
3400
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 form where the donation is entered. The problem is that if the donor is not a member, the On Not in List macro won't work for me bringing up a form with a new member number and all the fields that have to be filled out. I guess that the After...
4
4742
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 athletes. I have now learned how to join two different tables in a query so that I might generate a report. Specifically, student athletes at a community college are required to graduate with an AA or AS degree. Consequently, various steps are in...
1
2663
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 and the user leaves the textbox. However, if the entry is selected from the list of previously typed entries, the error does not disappear until the page is validated using the Page.Validate() method. I find this very weird (not to mention it may...
0
1589
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 that is available for the employee selected in the first combo box (this is completed). So if the user selects John Doe in the first combo box, and Mr. Doe has a disciplinary record in the Disciplinary Table, a "Disciplinary Incident Report" is...
4
5117
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 too long. A user selects a name from the combobox and runs a query. Originally, this combox was on a form in an MS Access ADP which was linked directly to our sql server. The combobox populated withins millisecnods. How can I achieve this...
4
7494
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. 'cause when i create a form with text box and change it to combobox the box is empty there are no records in it .
2
3627
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: TextBox3:
1
4011
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 am trying to update a contact record with FirstName and LastName contained on a table TblContacts via a Combo Box using the Limit to List function to add new contacts and perform a search to check if the contact is new or already exists on the...
30
26556
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 Tip came from one of our own resident Experts, mshmyob. In response to a Thread relating to this very Topic, mshmyob came up with a rather ingenious method to accomplish this task. He computed the Average Character Width of a String consisting of...
0
9653
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
10815
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
10524
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...
1
10562
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10236
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
9348
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, and deploymentwithout 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...
1
7768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.