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

fill combo based on selection of other combo

P: n/a
hi,

I would like to create two combo boxes. In the first one you can select
a user in the second one you can select a project. To simplify the
selection i would like to shorten the project list by just presenting
the projects the selected user is working on (using a where clause with
the userid filled in). Does onyone know how to achieve this?
Kind Regards,

Antoine Janssen

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Use the OnChange event to trigger a query to get and populate the
"Projects" combo box. You will need to have the userid included in the
user combo box. When the user name is chosen this triggers the
OnChange event. Put code into the OnChange event to get the userid of
the user selected. Then create the SQL statement to get the projects
assigned to the user. Using the returned data, populate the Projects
combo box.
It would goe something like this.

Form OnLoad - populate user combo box
User selected
OnChange triggered - in Sub Combo_OnChange add code to do the following
Get user id from selection
SQL statement to select projects where userid = userid
Iterate through returned recordset to populate Project combo box

Nov 13 '05 #2

P: n/a
On 17 Jun 2005 04:00:42 -0700, Antoine Janssen wrote:
hi,

I would like to create two combo boxes. In the first one you can select
a user in the second one you can select a project. To simplify the
selection i would like to shorten the project list by just presenting
the projects the selected user is working on (using a where clause with
the userid filled in). Does onyone know how to achieve this?

Kind Regards,

Antoine Janssen


Leave the Rowsource of the second combo box (Combo2) blank.

Code the Combo1 AfterUpdate event:

Combo2.RowSource = "Select ProjectName from tblProjects Where
tblProjects.UserID = " & Me!Combo1 & " Order By ProjectName;"

Change the field and table names above as needed.
The above assumes the UserID is the bound column of Combo1 and is a
Number datatatype.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3

P: n/a
You can simplify things a little bit by using the contents of the first
combo box as part of the SQL for the second:

Combo2 rowsource:
Select Project
From Table

Where Table.User = Form!Combo1

In combo2's gotfocus event and combo1's afterupdate event add a
combo2.requery.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.