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![cboSegment]
-
If IsNull(Me!cboDivision) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT DISTINCT tblSegment.SegmentID, " & _
-
"tblSegment.SegmentName " & _
-
"FROM TblLocationsMM INNER JOIN tblSegment " & _
-
"ON TblLocationsMM.SegmentIDFK = tblSegment.SegmentID " & _
-
"WHERE [DivisionIDFK]=" & Me!cboDivision
-
-
End If
-
Call .Requery
-
-
'Have the first dropdown list of cboSegment visible
-
If Me![cboSegment].ListCount > 0 Then
-
Me![cboSegment] = Me![cboSegment].Column(0, 0)
-
-
End If
-
End With
-
-
End Sub
I follow this method for the 4 other cascading combo boxes that are displayed on my form. Each selection adds an additional parameter to set the row source for the next combo box. I achieve this though my “Where” statement (See below): - Private Sub cboSegment_AfterUpdate()
-
-
'First Make sure other combo boxes are null
-
Me!cboWrkReg = Null
-
Me!cboCreditReg = Null
-
Me!cboBrokerType = Null
-
-
'When the Segment is selected, the appropriate Working Region list will
-
'display in the drop down list of CboWrkReg
-
-
With Me![cboWrkReg]
-
If IsNull(Me!cboSegment) Then
-
.RowSource = ""
-
-
Else
-
.RowSource = "SELECT DISTINCT tblWrkRegion.WrkRegID, " & _
-
"tblWrkRegion.WrkRegionName " & _
-
"FROM TblLocationsMM INNER JOIN tblWrkRegion " & _
-
"ON TblLocationsMM.WrkRegIDFK = tblWrkRegion.WrkRegID " & _
-
"WHERE [DivisionIDFK]=" & Me!cboDivision & _
-
"And [SegmentIDFK]=" & Me!cboSegment
-
-
End If
-
Call .Requery
-
-
'Have the first dropdown list of cboWrkReg visible
-
If Me![cboWrkReg].ListCount > 0 Then
-
Me![cboWrkReg] = Me![cboWrkReg].Column(0, 0)
-
End If
-
End With
-
End Sub
In the above example, the user would make a selection on my first combo box [cboDivision], now the second combo box [cboSegment] displays the first on the list based on the selection made in [cboDivision]. If the user does not actual click/select into [cboSegment] than my third combo box [cboWrkReg] is not going to have the correct drop down list.
If I do click/select [cboSegment] even though the first on the list is my choice the list choices in [cboWrkReg] are correct.
Now to my question, is there a simple code that I can put into my cboDivision_Aft erUpdate that will not only display the first on the list but will trigger a click/select action so that the appropriate lists for subsequent combo boxes on the form will be correct?
I am thinking the solution I would apply to my other combo box AfterUpdate events but I am lost on how to solve...
Thanks for any ideas you may have.
Keith.
3 3987
You can simply use the OnChange Event for each of your combo boxes, as you change them, then you can trigger the event that will update the next set of control(s) on your form.
Hope that helps,
Joe P.
You can simply use the OnChange Event for each of your combo boxes, as you change them, then you can trigger the event that will update the next set of control(s) on your form.
Hope that helps,
Joe P.
So would I need the same coding in both the AfterUpdate and in the OnChange Event or eliminate the AfterUpdate coding and just simply move it to a OnChange event?
Thanks for the idea.
Keith.
In the end I used another technique by disabling the combo boxes (setfocus.enabl e = False), except for the first, until a selection had been made in the first.......... .............
I included a command button I called "Reset Selections" to give the user the ability to reset previous selections if they wanted to make other choices.
Keith.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cognoscento |
last post by:
I'm currently putting together a database for my work (not an expert by
any stretch, so muddling through as best as I can... you know the
story...) and I could use some advice and hand-holding
I've got a subform with a series of cascading combo boxes (thanks to
the Access tutorials on fontstuff.com) that let the user assign
categories to items, in this case photos. This is being done to help
constrain user selections and keep the...
|
by: Edwinah63 |
last post by:
Hi everyone,
Please let there be someone out there who can help.
I have two BOUND combo boxes on a continuous form, the second being
dependent on the first. I have no problem getting the second combo to
change depending on what values the user selects in the first box, it's
just that every time the user changes the first combobox, the second
combobox FOR EVERY RECORD goes blank.
|
by: Rabbit |
last post by:
Cascading Combo/List Boxes
This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one determines the available options in the other.
TERMINOLOGY
Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
|
by: buddyr |
last post by:
Hello,
Yesterday I recieved help with two cascading combo boxes on an access form.
I went the link http://www.fontstuff.com/access/acctut10.htm
And basically used their first example.
Now I may need 3 cascading combo boxes and I cannot figure out how to do that.
Can you help?
Thank you
|
by: kcdoell |
last post by:
I have three tables:
One for the Division location:
tblDivision
DivisionID = Autonumber
DivisionName = Text
One for the Working Region:
tblWrkRegion
| |
by: klarae99 |
last post by:
Hello,
I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields below.
tblOrg
OrgID, AutoNumber, PK
ZipID, Number, FK
tblState
StateID, AutoNumber, PK
|
by: Toireasa |
last post by:
Hi,
Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience!
I'm using Access 2007, in XP. I'm currently trying to set up a whole pile of cascading combo boxes of different levels of complexity, so I started with the easiest set - and can't even get that to work (even using the tutorial on this site at...
|
by: 20028431 |
last post by:
This is driving me mad!
I have been trying for 3 days now to work out how to do this with no success.
I have tables for Customer, Bookings, Entertainment, Act, Agent, and several others.
I have created a form to view existing bookings with Customer details as mainform and Bookings and Entertainment as subforms and this works fine.
I am trying to create forms to allow the booking clerk to enter a new Booking and am looking to have a...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |