473,657 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to with a combo box

When clicking an item from a drop down list on a combo box, how does one
make another combo box make a selection from it's own list? No matter what
event I use for my code in the first combo box, seems to always generate an
error when I try and refer to the other combo box.

I'm aware of the necessity of setting the focus on the second box before
referring to it, unless one is using the default value. I'm too tired to
type out everything I've been playing around with (I've been at it for a
while now) and no matter what I always get some sort of error or unwanted
results. I'm hoping this is not something unusual and that someone can
simply show me a generic example of what might work.

Thanks,

Gord
Sep 3 '08 #1
4 2786
Gord wrote:
When clicking an item from a drop down list on a combo box, how does
one make another combo box make a selection from it's own list? No
matter what event I use for my code in the first combo box, seems to
always generate an error when I try and refer to the other combo box.

I'm aware of the necessity of setting the focus on the second box
before referring to it, unless one is using the default value.
Actually that is incorrect. You only need to set focus to use the Text
property and that is almost never the one you want. You want the Value
property which can be set without first setting focus.
I'm
too tired to type out everything I've been playing around with (I've
been at it for a while now) and no matter what I always get some sort
of error or unwanted results. I'm hoping this is not something
unusual and that someone can simply show me a generic example of what
might work.
All it should take is...

Me.ComboBoxName = SomeValue

Is it a multi-column ComboBox? That can change things since you might need
to set the value to one found in a column that is not the one you see.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 3 '08 #2
Typically the first combobox has the value of the primary key in some table.
We'll call it CustomerID in TblCustomer. Then the second combobox has the
value of the related foreign key in another table. We'll call it CustomerID
in TblOrder. So in the first combobox you choose a customer and in the
second combobox you choose from a list of orders by that customer. The
rowsource of the first combobox is a query based on TblCustomer. CustomerID
is the first column in the query and the Bound Column property of the
combobox is 1. The combobox is named CustomerID. The rowsource of the second
combobox is a query based on TblOrder. OrderID is the first column in the
query, CustomerID is the second column in the query and the Bound Column
property of the combobox is 1. The combobox is named OrderID. The criteria
for CustomerID is Forms!NameOfYou rForm!CustomerI D.

Put the following code in the AfterUpdate event of the first combobox:
Me!OrderID.Requ ery
Me!OrderID.SetF ocus
Me!OrderID.Drop Down

When you select a customer in the first combobox, the second combobox will
dropdown and only display
orders by the customer you selected. Focus will be on the second combobox.

Steve

"Gord" <x1******@telus .netwrote in message
news:FKnvk.1160 1$nu6.3003@edtn ps83...
When clicking an item from a drop down list on a combo box, how does one
make another combo box make a selection from it's own list? No matter
what event I use for my code in the first combo box, seems to always
generate an error when I try and refer to the other combo box.

I'm aware of the necessity of setting the focus on the second box before
referring to it, unless one is using the default value. I'm too tired to
type out everything I've been playing around with (I've been at it for a
while now) and no matter what I always get some sort of error or unwanted
results. I'm hoping this is not something unusual and that someone can
simply show me a generic example of what might work.

Thanks,

Gord

Sep 3 '08 #3
I just figured it out.

I can click one combo box and set the other combo's value by applying the
appropriate column value from the combo just clicked. This may set the
listindex of the second combo to an incorrect record but by setting up a
public boolean I can determine which combo was clicked. I'll use the
listindex from that combo to verify the record I want.

Thanks for your efforts.

Gord
Sep 4 '08 #4
Gord wrote:
....
Maybe I misunderstand, but I'm not finding to be true what you say
about a combo box selecting the first value in its bound column that
has duplicates "even if you make the selection manually". When I
drop the box and click on a selection I'm finding that the listindex
property sets to the row I clicked on and not on the first one with a
matching value in its bound column. ...
Just tested in Access 97 and 2003. Given a Combo with columns...

John Doe 1
Jane Doe 2
Tom Doe 3
Harry Doe 4

....with the bound column being the second one, The Combo displays "John" no
matter which row I select from the drop-down. That is what I was describing
in case it wasn't clear.

You are correct that if I display the ListIndex property in a MsgBox in the
AfterUpdate event it will reflect the index of the row I selected, but if I
check the ListIndex again (after AfterUpdate has completed), it always
reflects the ListIndex value of the first row in the list with the bound
value I picked. In the example above that value is zero.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 5 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2555
by: mark | last post by:
I've been working on an Access 2000 database for a couple of weeks now. I took a course in access about a year ago, a crash course, and I learned a ton, but I didn't touch Access for the year since then so I forgot everything I learned : ( So this little project I envisioned has turned out to be much harder than I thought. But I think I'm close with it, so I want to see it through. What I wanted to create is a database that will track my...
2
2233
by: misschristalee | last post by:
I'm having a brain blockage day.... Scenario: Search Form with 6 text boxes Query has same six fields Each has this IIF: IIf(IsNull(!!),"",!!) with each dictating the correct text box of course. SQL dictates... If text box 1 isNull do nothing or do this OR if text
2
2283
by: Wayne | last post by:
I've implemented the following successfully on a single form before, but the continuous form is giving me problems. I have 2 combo boxes, Combo 1 and Combo 2. The values in Combo 2 are dependent on the value selected in Combo 1. I run the code: Me.Combo2.Requery on the Combo 2 "On Enter" event to refresh the values in Combo 2 to reflect the value chosen in Combo 1. Everything works fine for the first record. However when I move to the...
8
12090
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
4
2342
by: John Tyce | last post by:
The problem that I am now having, involves refreshing controls. I have allot of text boxes, several combo boxes and grids. These controls are showing live data from an Oracle database. I have dates in a combo box in my tool bar that are associated with the particular report that the user is opening. When the user picks a different date all of the data in the controls should reload. I originally built an SDI application but needed my tool bar to...
3
3649
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.
2
2442
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to populate the combo (for a list of 2500). Can anybody optimize the code. I tried Duffs devise instead of 'for loop', but no improvement.
0
2921
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a lot of time trying to figure it out, over the years. It finally dawned on me a couple of weeks ago how to do this. A couple of notes: 1) This is written for a different audience than CDMA; it's written for
1
2905
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
0
8411
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
8323
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
8739
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
6176
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
5638
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
4173
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...
1
2740
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
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.