leaning
Dec 19 2011, 01:24 PM
Hello!
I have a DogName combobox that uses tblDog.tblDogIDpk, but displays tblDog.DogName.
So, the text is displayed in the combobox dropdown, but the key for that text (1,2,3,etc.) is what is stored in the table.
1) When I click on the combobox on the form and click "Find", it wants to search for the keys rather than text.
2) Also, I want to enable another combobox based on what's displayed in the DogName combobox. I tried "If DogName= "Fido" then disable cmbCat", but again, that box is tied to the key. So I have to set it up like "If DogIDpk = 12, then disable cmbCat." I'd rather refer to the text rather than a key number.
Hopefully, someone can see what I am getting wrapped around and give me a nudge.
Thanks!
Lost
leaning
Dec 19 2011, 01:24 PM
Hello!
I have a DogName combobox that uses tblDog.tblDogIDpk, but displays tblDog.DogName.
So, the text is displayed in the combobox dropdown, but the key for that text (1,2,3,etc.) is what is stored in the table.
1) When I click on the combobox on the form and click "Find", it wants to search for the keys rather than text.
2) Also, I want to enable another combobox based on what's displayed in the DogName combobox. I tried "If DogName= "Fido" then disable cmbCat", but again, that box is tied to the key. So I have to set it up like "If DogIDpk = 12, then disable cmbCat." I'd rather refer to the text rather than a key number.
Hopefully, someone can see what I am getting wrapped around and give me a nudge.
Thanks!
Lost
Bob G
Dec 19 2011, 01:26 PM
what is the bound column of the combobox ??
Doug Steele
Dec 19 2011, 01:29 PM
When you simply refer to a combo box, you're going to get the value of the BoundColumn for the selected row.
To get the value of any other column, use the Column collection: If Me!DogIDpk.Column(1) = "Fido" ...
Note that the Column collection starts numbering at 0, so Column(1) refers to the value in the second column of the selected row.
leaning
Dec 19 2011, 01:40 PM
Bob G,
1) Record Source: Is a query. Column 1 is 0" long (tblDog.tblDogIDpk), Column 2 is 2" long (tblDog.DogName)
3) Bound Column: Column 1 (tblDog.tblDogIDpk)
4) Control Source: tblDogStuff.tblDogIDfk
HTH
Lost
Bob G
Dec 19 2011, 01:42 PM
change the boundcolumn to 2 and see if that works for you
leaning
Dec 19 2011, 02:44 PM
Bob G,
Here is how I dumb it down for me for comboboxes:
Record Source: What you want to see in the combo box.
Bound Column: What column of the underlying query is going to be put into the storage table.
Control Source: What field of the storage table is going to be used.
Using this, if you change the bound column to 2, now the DogName (Fido, Rover, etc.) gets put in the storage table. If that happens, you get a bunch of Fidos and Rovers being stored instead of just the numeric keys (1, 2, 3).
DougSteele had what I needed: Conditional Format> Expression is: [cmbDogIDpk].Column(1) = "Fido". Then click the Enabled button. You have to refer to the name of the object rather than the name of the field.
Thanks, all! And sorry about triple posting!
Respectfully,
Lost
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.