473,698 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comboboxes with dynamic dropdown menu

68 New Member
I have a form with a few combo boxes that I would like to have their menu entered dynamically.

The first box is department and it holds all the departments in the organization. When I select a department in this box I would like the second combo box, which is "user" to be populated with only the users in this department. As it is right now users are being drawn from one table that is populated with all the users in the organization.

After selecting the user i would like the the hardware combobox and the software combo box to be populated with only the assets that are assigned to them. These values are pulled from their respective tables which contain all the assets in the organization.
Jun 9 '09 #1
11 12107
hjozinovic
167 New Member
This should not be that hard. The combo box menus should be based on queries that have the appropriate combo boxes in their criteria section.
Like this:
1. Department box is based on query which is including all the departments.
2. User combo box must be based on a query that includes all the users WHERE Department ID = DepartmentCombo Box
3. the same goes for others...
Let us know how it's going with this.
Jun 9 '09 #2
ChipR
1,287 Recognized Expert Top Contributor
This Bytes insight article should help: Cascading Combo/List Boxes
Jun 9 '09 #3
NeoPa
32,569 Recognized Expert Moderator MVP
You should find the whole issue covered in Example Filtering on a Form.

Let us know how you get on.
Jun 9 '09 #4
KingKen
68 New Member
Thanks a lot for the ideas shared. I tried the Cascading combo/List Box and am not getting through. Here are the details.

Expand|Select|Wrap|Line Numbers
  1. Departments
  2. DeptID - AutoNumber, PK
  3. DeptName - Text - Name of department
  4.  
  5. Location Officer
  6. LocationOfficerID - Autonumber, PK
  7. LocationOfficer - Text, Name of location or officer asset assigned to
  8. Department - Number
The form contains a combo box named LocationOfficer and one named Department. When i select the department the location officer should be populated but nothing happens, not even an error.

I used the following codes on the Department Combobox Afterupdate event

Expand|Select|Wrap|Line Numbers
  1. Private Sub Department_AfterUpdate()
  2. With Me.LocationOfficer
  3.     If IsNull(Me!Department) Then
  4.        .RowSource = ""
  5.     Else
  6.        .RowSource = "SELECT [LocationOfficer]" & _
  7.                     "FROM [Location officer] " & _
  8.                     "WHERE [Department]=" & Me!Department
  9.     End If
  10.     Call .Requery
  11. End With
  12. End Sub
Jun 10 '09 #5
KingKen
68 New Member
I tried avoiding codes and using a query. this works on the first attemp but does not requery when the value in the department combobox changes. here is the SQl codes:
Expand|Select|Wrap|Line Numbers
  1. SELECT [location officers].LocationOfficerID, [location officers].LocationOfficer
  2. FROM [location officers]
  3. WHERE ((([location officers].Department)=[Forms]![SupportLogsForm]![Department]))
  4. ORDER BY [location officers].LocationOfficer;
  5.  
Jun 10 '09 #6
FishVal
2,653 Recognized Expert Specialist
Fields set is different in post #5 and post #6.

P.S. You couldn't avoid code at all. Virtually, you could, but this won't make your application more robust.
Jun 10 '09 #7
NeoPa
32,569 Recognized Expert Moderator MVP
@KingKen
I never realised that article suggested changing the Row Source. I would not recommend this approach.

Please see the other article and let us know if that works for you.

Fish makes another good point :
Your different posts reflect different and incompatible names. This is a very bad idea. If you want people to consider your problem you should really be very careful to represent it accurately.
Jun 10 '09 #8
KingKen
68 New Member
Thanks for the observations and suggestions. I spotted the inconsistency in the table name [Location Officers] this was also an error in my codes and i corrected it. This however did not caused the program to function. I read the second article and cannot seem to matchup the concepts and worst so the codes with what i want to achieve. some how to me the first article seems like a simple solution that could work and for my ignorant sake i hope it ca. Can it?

You probably could tell by now that I am not so good at what I am trying to do so I am always looking for the easiest way out. The second article posed a bit of a challenge even reading, much more understanding.

So here are some suggestions I have:

What if I move these codes to the on gotfocus event of the LocationOfficer combo box? Would this work

Notice that I am focusing on the Department and LocationOfficer combo boxes right now. I believe that if I get this right then I can replicate it for the rest.
Jun 11 '09 #9
NeoPa
32,569 Recognized Expert Moderator MVP
Well, that's me told anyway (author of 2nd article) :D I thought with the examples provided and all it was fool-proof.

The first article can work I'm sure, but changing the SQL itself, instead of passing a simple parameter to the code that opens the form is not a good plan. Workable but untidy (Sorry Rabbit).

If that can work for you though, go for it :)
Jun 11 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3439
by: jorntk | last post by:
How can i make a drop down menu that are dynamiclly generated base on the value selected in another drop down menu? thanks nad regards Jorn
1
2549
by: Andrea Bampi | last post by:
I'm just trying to do my first experiments with js, but I need some good examples to start with.. I need to design a dynamic form with two dropdown menus picking their select values from a db: my problem is, how can I make the selection in the first menu affect the value list in the second, without using any buttons? I mean, you just have to click on the first menu and select the desired item, then the proper select list is "loaded" into...
3
10755
by: Robert Mark Bram | last post by:
Hi All! Has anyone seen an example of the following javascript powered control: - a dropdown select menu - the width of the control is set. Assume by "control" I mean the visible part of the drop down before a mouse click occurs. - the width of the list when selected is dynamic - the width of the list can grow beyond the width of the control without changing the width of the control.
4
1968
by: Kathy | last post by:
In my custom menu one menu item opens a form to add new Makes to TblMakes and another menu item opens a form to add new Models to TblModels. I have a form that has a combobox for Makes and a combobox for Models. In both comboboxes I use the NotInList event and code to allow users to enter Makes and Models that are not in the database. When the form is open, I want to limit the users to entering new Makes and Models in the comboboxes and not...
7
4266
by: Bertman105 | last post by:
Hey all, Heres the situation: I have a form page that needs to have multiple drop down menus that is pulling their options from a database. Right now I have one working out of 3. So that is one issue, now the issue that I am having with the one that is working, is that it is not writing anything to the database. No matter what you select, the database is empty. Any help would be sweet. So here is the form page, with just a few text...
0
1410
by: Just Me | last post by:
My Dynamic dropdown menus are appearing above the text below. How can I prevent this, I have tried setting the zorder high for them, but it makes not difference. Cheers
1
3121
by: Steve Richter | last post by:
I am using <div align=centerto center a horizontal menu on the page. Problem is the center align of the div is rippling down to the menu items and causing the text of the dynamic popup sub menu items to be centered also. How can I center my navigation menu without centering the menu item text? thanks, -Steve
1
1916
by: phpnewbie2007 | last post by:
I have 2 dynamic PHP dropdowns: The second dropdown populates from the first, depending on what is selected in the first. The page is showing issues in a department: The first dropdown consists of departments- It has 3 options All issues, dept A, dept B If dept A is chosen in the first dropdown, the second dropdown shows all members in dept A and all issues are shown for dept A are shown below. Now if i choose a member in second...
1
2659
by: sydd | last post by:
Hi, I was wondering if it's possible to create a dynamic dropdown menu from this code. if($rs->getNumRows() > 0){ $intProjectCount = 1; $htmlOut ="<table width='100%' border='0' align='center' cellpadding='1' cellspacing='0'>"; foreach($rs->fetch() as $prs){ $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs."\">".$prs."</a></td></tr>";
0
8678
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
8609
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,...
1
8899
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,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.