By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

select item in listbox that matches selected item in combo box

P: n/a
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 AddToModelsListFormAddButton_Click()
Dim strNewModel As String
strNewModel = Me.AddToModelsFormNewModelNameTextBox.Value
DoCmd.GoToRecord , , acNewRec
Forms!ItemInformationForm!ModelLookupComboBox.Valu e = 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!ItemInformationForm!ModelListBox.Value = strNewModel
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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!ItemInformationForm!ModelListBox.requery

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

Me.ModelListBox.requery
Darryl Kerkeslager


"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
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

P: n/a
Requery the listbox

me.lbx.Requery
Nov 13 '05 #3

P: n/a
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!ItemInformationForm!ManufacturerListBox.SetF ocus
Forms!ItemInformationForm!ManufacturerListBox = strNewManufacturer
Forms!ItemInformationForm!ManufacturerListBox.Requ ery
Forms!ItemInformationForm!ManufacturerLookupComboB ox.SetFocus
Forms!ItemInformationForm!ManufacturerLookupComboB ox.Value =
strNewManufacturer

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

rc*********@yahoo.com (RC) wrote in message news:<3c**************************@posting.google. 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 AddToModelsListFormAddButton_Click()
Dim strNewModel As String
strNewModel = Me.AddToModelsFormNewModelNameTextBox.Value
DoCmd.GoToRecord , , acNewRec
Forms!ItemInformationForm!ModelLookupComboBox.Valu e = 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!ItemInformationForm!ModelListBox.Value = strNewModel

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.