Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box display 1

Status
Not open for further replies.

Fonzie

MIS
Feb 16, 2001
74
CA
I have a form with two combo boxes, lastname and firstname. When a lastname is chosen from the first combo box, this limits the selections in the second combo box to only first names that correspond to that last name. What I would like to happen is when a last name is chosen from the lastname combo box, the first firstname is displayed in the firstname combo box, instead of being blank. Anyone?
 
I really messy way of doing it would be to open a recordset and set the first value to the value of the second combobox on the 'after update' event of the first, making sure that the second combo box doesn't already have a value, but I'm sure someone can come up with something cleaner than this.
Mike Rohde
rohdem@marshallengines.com
 
Fonzie:

Unless it's absolutely necessary to have a dual combo box set up as you describe, I would suggest concantenating the LastName and FirstName as one field and basing the combo box on that.

Would that be possible in your application?
Larry De Laruelle
larry1de@yahoo.com

 
I used to use macro to run query (according to first combo box value) of second combo box in lost focus event of first combo box. It worked! I hope it would help you too...
 
Maybe I can answer your question with, I don't understand exactly how combo boxes work but! If you display 4l columns in a combo box and the column width's property is set to 1";1";1";1" and you click on one of the rows the combo box resets to display only the fires row. I would like to find out how you can re-display all of the rows in the selected recored which may answer your question. However if a second combo box is predicated on picking one of the recoreds in the first box (your example of the first box displaying Last name) which then causes the second combo box to display the same last name and multiple first names. If you set the width's property of the second combo box to 0";1; and the order of display is last name, first name; only the first name will be displayed.

Hope this helps.

If anyone know how to re-display the entire row once selected let me know.

Bud
 
I had something similar, set up the query for the second combo with [forms]![yourform]![lastname] as the criteria for the lastname here, getting all the first names that go with that last name.
then in afterupdate for the first combo have code like this:
dim strmess as string
me!cbo2.requery
me!cbo2 = me.cbo2.column (0,0)
if cbo2.listcount > 1 then
strmess = "pick name"
msgbox strmess
cbo2.setfocus
cbo2.dropdown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top