473,406 Members | 2,343 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,406 software developers and data experts.

how to access index of combobox field?

BeemerBiker
I have a combo box field "Grouping" in "MyTable" and set the design to
Expand|Select|Wrap|Line Numbers
  1. Row Source: SELECT Categories.Grouping, Categories.index FROM Categories; 
  2. BoundColumn:   1
  3. Column Count:  2
  4. Column Widths: 1",0"
  5.  
How do I issue a select query so I can just get the index, and not the actual text value?

I know a join would work where the join would be on Categories.Grouping=MyTable.Grouping and I could pick up Categories.index. However, since there are already 2 columns in MyTable at that single field, I thought I could avoid the join

thanks for looking
Feb 27 '09 #1
2 5736
Stewart Ross
2,545 Expert Mod 2GB
Hi. It is much simpler to do than you imagine; use the Columns property of your combo box to refer to the second (hidden) column. Columns are numbered from 0, with the 0 column being the leftmost, column(1) the next, and so on, regardless of whether or not they are visible to users.

In this case, the index value can be referred to in another textbox or within a VBA function as

[Grouping].Column(1)

Using hidden columns in combo or listboxes to store lookup values based on the main row displayed can be very useful, and I'd advise that you look at the combo rowsource query as the place where you should start. You can make the combo itself do the lookup for you by including suitable fields in your combo rowsource query, then use the Columns property to display the additional data about the item chosen.

For example, a 'select user' combo can have the user's department and department ID in its columns, and these in turn can be shown on a userform by using unbound textboxes whose control source propery is set to the column concerned. Such a property setting is like this, assuming that the value to display is in the fourth column of a combo called [User ID]:

=[User ID].Column(3)

-Stewart
Feb 27 '09 #2
Thanks Stewart, that is exactly what I am looking for.
Feb 27 '09 #3

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

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
6
by: DFS | last post by:
I swear that sometimes things behave differently from one day to the next. Access 2003. Example: I have 4 radio buttons that set the rowsource of a combobox depending on which option you choose....
0
by: Steve | last post by:
Hi all I have a ComboBox that is bound to a table. The DisplayMember is 'Description' and the ValueMember is 'CountyID'. This field exists on a form that displays a Person, and I need to display...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
2
by: SKarnis | last post by:
We are trying to rebuild a current Access 2002 (XP) mdb program to VB.NET with a SQL database - we are having problems with a suitable combobox. There are many threads discussing multiple column...
2
by: jen | last post by:
i have select query that returns multiple records and populates a combobox/pulldown. once a selection from the pulldown is selected, i need to reference two or three fileds from the previous...
0
MMcCarthy
by: MMcCarthy | last post by:
The more data you include in your tables the more you will need to have indexes to search and sort that data. However, there is a balance between having enough indexes and too many. Too many...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
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,...
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...
0
agi2029
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,...
0
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...

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.