Populating Combo box problems

CherryinHove

New member
Local time
Today, 15:00
Joined
Nov 27, 2007
Messages
4
Hi,

I've been teaching myself Access recently and think I've been doing fairly well at it, unfortunately I've come across a small problem that has me completely stumped. I'm fairly sure there is going to be a reasonably simple solution to it but I've tried googling and searching through your forum but haven't had any joy yet so apologies if it is in here somewhere and this is a superfluous post but here is my problem...

I have a form which is for submitting data on employees. The first combo box is for selecting the manager of the team you are interested in. (This is the catchily named Combo27 and gets its data from " SELECT Managers.[Manager ID], Managers.[Manager Name] FROM Managers ORDER BY Managers.[Manager Name]; ")

The next combo box is the one where employess are selected. This gets the data displayed from the following query "SELECT Employees.[Employee Name] FROM Employees WHERE (((Employees.[Manager ID])=[Combo27])) ORDER BY Employees.[Employee Name]; "

Now. This works if you click on the manager box and select the correct manager. However, if you click on the employees box first, it populates itself with nothing and then even if you click on a manager in the manager box it still won't repopulate the employees box. It is also impossible to change the list in employees once a manager has been chosen.

I'm sure that it is going to be something as simple as putting something into the OnClick section in Combo27 but I can't for the life of me work out what expression or macro needs to be put in there. If anyone could help I would be hugely greatful.
 
You need to call combobox's requery method every time you want to refresh the containing data.

For example:

Sub Combo27_OnClick()

ComboBoxEmployee.Requery

End Sub
 
Unfortunately that gave me an error when trying to run it, but giving me the "requery" command helped greatly.

It was somply a case of bringing up the properties for Combo27 and in the On Click section putting "=[Employee Name].requery".

Thanks very much for pointing me in the right direction!
 

Users who are viewing this thread

Back
Top Bottom