473,748 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select item in listbox that matches selected item in combo box

RC
I have a form where the user enters the Model info. The user picks
the Model from either a combobox or listbox which both are filled from
the Models table. If the Model type isn't in the boxes, then the user
can click a button and add a new Model to the Models table. When the
user clicks the "Add new Model" button, a pop-up Form opens the user
types in the new Model name into a text box and a new record is added
to the Models table and the pop-up form closes and returns to the form
that is was opened from. After returning to the Model info form the
combo box has the newly added model selected, this is what I want.
How can I make the listbox also display the newly added model? My
code below is from the pop-up form.

Private Sub AddToModelsList FormAddButton_C lick()
Dim strNewModel As String
strNewModel = Me.AddToModelsF ormNewModelName TextBox.Value
DoCmd.GoToRecor d , , acNewRec
Forms!ItemInfor mationForm!Mode lLookupComboBox .Value = strNewModel

'The line above highlights the newly added model and moves it to the
top of the combobox
'The line below does NOT do the same to the ListBox

Forms!ItemInfor mationForm!Mode lListBox.Value = strNewModel
Nov 13 '05 #1
3 2430
Assuming that the Models table is the underlying recordset for the original
form, the pop-up form, the combo box, and the list box, you just need to
requery the listbox. You are sure that the Model has been added to the
table, right? Then just use:

Forms!ItemInfor mationForm!Mode lListBox.requer y

or, after you close the (modal) pop-up form :

Me.ModelListBox .requery
Darryl Kerkeslager


"RC" <rc*********@ya hoo.com> wrote in message
news:3c******** *************** ***@posting.goo gle.com...
I have a form where the user enters the Model info. The user picks
the Model from either a combobox or listbox which both are filled from
the Models table. If the Model type isn't in the boxes, then the user
can click a button and add a new Model to the Models table. When the
user clicks the "Add new Model" button, a pop-up Form opens the user
types in the new Model name into a text box and a new record is added
to the Models table and the pop-up form closes and returns to the form
that is was opened from. After returning to the Model info form the
combo box has the newly added model selected, this is what I want.
How can I make the listbox also display the newly added model? My
code below is from the pop-up form.

Nov 13 '05 #2
Requery the listbox

me.lbx.Requery
Nov 13 '05 #3
RC
Just in case anyone else has a similar problem HIGHLIGHTING items in
comboboxes and listboxes through code. I finally got it to work using
this code:

Forms!ItemInfor mationForm!Manu facturerListBox .SetFocus
Forms!ItemInfor mationForm!Manu facturerListBox = strNewManufactu rer
Forms!ItemInfor mationForm!Manu facturerListBox .Requery
Forms!ItemInfor mationForm!Manu facturerLookupC omboBox.SetFocu s
Forms!ItemInfor mationForm!Manu facturerLookupC omboBox.Value =
strNewManufactu rer

Plus the combobox needed to be bound to column 1 and the listbox
needed to be bound to column 2

rc*********@yah oo.com (RC) wrote in message news:<3c******* *************** ****@posting.go ogle.com>...
I have a form where the user enters the Model info. The user picks
the Model from either a combobox or listbox which both are filled from
the Models table. If the Model type isn't in the boxes, then the user
can click a button and add a new Model to the Models table. When the
user clicks the "Add new Model" button, a pop-up Form opens the user
types in the new Model name into a text box and a new record is added
to the Models table and the pop-up form closes and returns to the form
that is was opened from. After returning to the Model info form the
combo box has the newly added model selected, this is what I want.
How can I make the listbox also display the newly added model? My
code below is from the pop-up form.

Private Sub AddToModelsList FormAddButton_C lick()
Dim strNewModel As String
strNewModel = Me.AddToModelsF ormNewModelName TextBox.Value
DoCmd.GoToRecor d , , acNewRec
Forms!ItemInfor mationForm!Mode lLookupComboBox .Value = strNewModel

'The line above highlights the newly added model and moves it to the
top of the combobox
'The line below does NOT do the same to the ListBox

Forms!ItemInfor mationForm!Mode lListBox.Value = strNewModel

Nov 13 '05 #4

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

Similar topics

4
8842
by: mr_burns | last post by:
hi, using javascript, how do i select an option in a combo box? i have tried looking on the internet but dont really know what i should be searching for. what i want to happen is that when a function is called a line of code will select a specific option in a combo box. something like: //excuse the dodgy syntax
4
11264
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting at the top of the list moving down towards the bottom. The problem I was having was that the <select> control was scrolling back to the top of the page after the postback and the user would lose their place in the <select> control forcing them to...
19
3565
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main form, the subform returns the records based on the two criteria. The criteria used on the main form are values selected in two list boxes. When the user clicks on the first list box (lstCollege), it returns values in the second list box...
14
2932
by: Jos? | last post by:
This one droves me completely mad. I did not succeed to exploit the track given to me by Bob. I have : three tables : Clubs, Persons and ClubsPersons that join the two first in a many to many relationship. Club has two (2) fields : ClubId (Autonumber) and ClubName (Text). Peoples has two(2) fields : (PersonId (Autonumber) and PersonName (Text) ClubsPersons has two (2) fields : ClubId (LongInteger) and PersonId
2
1564
by: Andy Warner | last post by:
Hello all, I have a listbox with 2 'fields' and a choice of 100 or so items that can be selected. User can select multiple items (i'm using the simple multiitem model) as normal. however, I want several buttons that will select a set of these items if pressed.
3
4641
by: google | last post by:
Hello, I am trying to create a listbox that users can select multiple entries on. I want Access to put each on of those selections in a different row on a particular table. This table will also include the primary key of the parent form of the form that has the listbox. Here is the code that I have. Right now it will put all of the selections from the listbox into one row. Private Sub Category_Click()
1
2243
by: sab | last post by:
Hi, We have a web form with a listbox. The listbox is a multiple select listbox and has data that looks something like: ALL Unit 1 Unit 2 Unit 3 Note: "ALL" is always the first item in the list.
5
4084
by: Matthew Wells | last post by:
I have a listbox set to simple multi select. For this example, users only select one item at a time. I have command buttons on the form for First, Previous, Next, Last, New (record). The form and listbox are unbound. The listbox rowsource is a value list. The list box has about sixty items in it. Each item in the list box corresponds to a record in the database. When a user selects a row in the list box, the record is retrieved. The...
1
8063
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just a commandbutton on my form). The biggest problem I'm having is that I can't (don't know how) populate a combobox on static items such as "True, False, Any." The Any field, would be selected by the user to find all records where that fields is...
0
8995
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
9378
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
9253
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
8250
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...
1
6798
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
6077
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();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2216
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.