Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Using Autonumber column in combo box

Status
Not open for further replies.

ShadwSrch

IS-IT--Management
Mar 9, 2005
72
US
I have a simple database for keeping track of who has what keys for our church.
[key] table
key_id(autonumber)
building_id(foreign key to building table)
kdescription(text field describes what the key opens)
keycode(text field for code stamped on key for ID
kblank(code that indicates blank to use to make the key)

[building] table
building_id(autonumber)
bname(text field to hold building name)

I have an unbound combo box that users can chose the building. Here is the row source:
SELECT building.bname, building.building_ID FROM building;

Changing this causes a second unbound combo box to be populated with just the keys for that building.

This is the code for the change event onthe first combo box:
cboKey.RowSource = "SELECT key.keycode, key.kdescription, key.key_id, key.building_id FROM [key] WHERE key.building_id=" & Me.cboBuilding.Column(1) & ";"

I can use cboKey.Column(0) and cboKey.Column(1) with no problem...the problem is when I try to use cboKey.Column(2). I can't do anything with it. I am trying to add it to a sql command, but it is always blank even though the key_id is obviously a required field, and populated for all records on the table.

When I tried to assign it to sometextbox.value...the text box is blank.
When I tried to assign it to somelable.caption...the lable is blank.

How can I use this field?

I would appreciate any help you could give.
 
G'day mate,

At a guess you've not set the column count property to 4, you've copied the other combo which has column count=2?

Hopefully that's it.

JB
 
I set the ColumnCount to 4, and set the column widths of the other columns to 0"...

The result is that I can now use the information, and I don't see the columns I don't need! Thanks!

One thing though...the ColumnCount on both comboboxes was set to 1.

It is working now, so I guess it doesn't matter, but I am curious to know why it worked before...

Warning: The following is wild speculation
It is like you can use the ColumnCount + 1 and no more...I could test that later...but I probably will never get around to that

JBinQLD, thanks again for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top