473,725 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2203
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.RowSourc e = "Select ProjectName from tblProjects Where
tblProjects.Use rID = " & 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
1602
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 other combo box.In fact Application is selected based on Group,Division & Names.But in many cases there are Divisions which do not have any Names. I need to select Applications either on two conditions,one if Names are available, which...
4
4712
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
2609
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 have a split Access database- tables and front end both sit in at users local drive(except when theuser connects to the server to import update files). I have two unbound combo boxes, when I make a selection to the first one the second's row source...
1
2000
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 the form, based on the selection in the combo box. I have been doing this quite successfully by having the combo box rowsource query contain all the fields and simply use the correct column to fill in the text boxes. e.g. me.txtState =...
7
11142
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 values for the second combo box (B) from a database. However, when I choose a value from the first combo box (A), the second combo box (B) populates as required, but if i change my mind about the selection from the first combo box (A) , the second...
3
3652
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" through "Phase 10" (there are 10 Phases I want to sort from) Once the phase has been selected a second combo box would populate.
4
13970
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 tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt I have populated tbl_OSE_Info table. I need to create a form that will store the data in tbl_Input I have racked my brain so much trying to figure out how to auto populate a field based on a...
1
3640
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 unbound combo box control
3
3985
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 list will 'display in the drop down list of CboSegment With Me! If IsNull(Me!cboDivision) Then
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.