473,413 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

fill combo based on selection of other combo

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
3 2185
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
Hello, I am developing an A2K application.In the subform ,I have around 4 combo boxes for Group,Division,Name and Application.The selection criteria of each combo is narrowed based on the value of...
4
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
3
by: geribosi | last post by:
I have a question that may have been asked numerous times, however from the previous postings no one seems to have a plausible explanation. This is a performance issue that is very common: I...
1
by: Tom G | last post by:
Hello, I need some advice on which way to resolve the following. On a form, the user will make a selection from a combo box, after the selection several different fields need to be updated on...
7
by: Doug | last post by:
Hi I have a combo box (A) that populates a following combo box (B) based on a selection. The selection from the first combo box (A) initiates an OleDbDataAdapter routine that extracts the...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
1
by: peasedm | last post by:
Okay this one has me stumped. I have a table called Review_Statements with the following columns: statementid type statement1 statement2 statement3 I have a form called SR_Review with an...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.