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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box And Combo Box Problem 1

Status
Not open for further replies.

ReportMan

Programmer
Aug 13, 2001
40
US
This seems like a very simple problem but it is driving me crazy. I have a form with two combo boxes, the 1st one (Location) uses a value list and the 2nd one (Building) uses a query. What I am trying to do is let the user pick a location from the first combo and using that value filter the second box to only show buildings for that location. The building table has a location field and a building field. This is the table I am basing my second combo box on.

The first combo box is named Employee Location and the second combo box is named Employee Building. I build a query selecting building where location is equal to combo box one value. It seems to work the first time but never again. I have put a after update event in the first combo box which says [Employee Location].requery, but it has no effect. I would appreciate any help in solving this problem.
 
It needs to requery the 2nd combobox:

[Employee Bulding].Requery

Ken
 
Hallo,

There's a FAQ in this forum called:

How do I limit the contents of one combo box based on the selection in another?

Which may be of help,

- Frink
 
In the after update event, set the Employee Building rowsource:

Me![Employee Building].RowSource = "Select [Building] FROM [LocationTable] WHERE [LocationTable].[Location] = '" & Me![Employee Location] & "'"

Code On!!! Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Hi

in the after update event of the Combo [Employee Location] you need [Employee Building].requery

In the OnGotFocus Event of the combo [Employee Building] put [Employee Building].requery

and please, please do not use embedded spaces in your control names (sorry a little fetish of mine) Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I am now getting an error on the OnGetFocus Event of the Combo [Employee Building]. It says that the expression is not a OLE Object. I am trying to tell it to requery the Combo [Employee Location].
 
Hi

My post said:

in the after update event of the Combo [Employee Location] you need [Employee Building].requery

In the OnGotFocus Event of the combo [Employee Building] put [Employee Building].requery Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

If I understand you correctly, you are saying to requery [Employee Building] in both the combo boxes? In the after update event of Combo 1 and in the ongotfocus event of combo 2.

Al
 
Ken,

The form is now working correctly except for one thing. When I click on the 2nd Combo box I get the message the Forms. is not a macro name. I am trying to point the OnGotFocus Event back to the 1st Combo box value. Even tho it gets a error message the combo box boxes the way it is supposed to. The correct data shows in the drop down and the correct value is placed into the table field. How do I correct the error message or at least suppress it? Any Ideas?

Al
 
Hi

On the basis of what I asked you to do, theer should not be an error message

What is the SQL of the combo [Employee Building]

What if any code do you have in any other event of [Employee Building]

What if any code do you have in the events of [Employee Location]

Please give the exact error message you are getting Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top