Re: referencing columns from list box?
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Feb 2007 13:16:20 -0500
Something is wrong with your application if Me.cboMemberYear.Column(1) is
returning C, I, J or F. You should only get those values if you're using
Me.cboMemberYear.Column(0) (or strictly referring to Me.cboMemberYear,
without the reference to Column)
Make sure your combo box has the correct number of columns defined.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Pendragon" <Pendragon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4A253913-EC65-4FBD-A193-06D840980BD4@xxxxxxxxxxxxxxxx
After I posted, I thought about the AfterUpdate - it's what I've done
elsewhere. Not sure why that didn't come to mind.
Regarding the second part: If I use Me.MyTextbox =
Me.cboMemberYear.Column(1), that will give me C, I, J or F depending upon
other selections. Is there a way to get Me.MyTextbox to display
Corporate,
Individual, Joint or Family instead of the letters? Column(1) is a field
that is a list box in the table. I could always do an IIF statement to
display the correct text, but I was curious if there was a way to
reference
that info without doing an IIF statement.
The simple version:
MyTable has a field called Forest. It's a list box with the following
values:
1;"Tree1";2;"Tree2";3;"Tree3"
Now I have a form with a combo box. The control source is Forest. The
values displayed are 1, 2 or 3. Is there a way to get the combo box to
display "Tree1", "Tree2","Tree3" without having to do IIF([Forest] = 1,
"Tree1", IIF([Forest] = 2, etc etc etc)?
"Douglas J. Steele" wrote:
"Pendragon" <Pendragon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CC1234A3-30B1-405E-B3E2-6666EE95C8A5@xxxxxxxxxxxxxxxx
Access03/WinXP
I have a form with a combo box (cboMemberYear) with a data source of
SELECT
MYear, Type, StartDate, EndDate FROM tblMembershipYears. "Type" is a
field
from the table and is a list box with values
"C";"Corporate";"I";"Individual";"J";"Joint";"F";"Family".
On my form, I have text boxes to serve only as reference information
for
the
user (they are locked).
First question is how do I set a text box to reference a column/value
of
the
combo box? In the control source, Me.cboMemberYear.[column(1)] and
Forms!frmMemberYearInfo.cboMemberYear.[column(1)] both yield a #Name?
error.
The control source would need to have an equal sign in front of it, but
I'm
not actually sure it'll work even with the equal sign there.
The normal approach is to put code in the combo box's AfterUpdate event:
Private Sub cboMemberYear_AfterUpdate()
Me.MyTextbox = Me.cboMemberYear.Column(1)
End Sub
The second question is that I want one of those text boxes to display
the
Description of the list box, not the single character abbreviation.
How
do
you get to the "sublevel", if you will, to display the correct data?
Not sure I understand this question. By refering to Column(1) above,
you'll
get the full description. The Column collection starts counting at 0, so
1
is the 2nd column.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
.
- Follow-Ups:
- Re: referencing columns from list box?
- From: Ron2006
- Re: referencing columns from list box?
- References:
- Re: referencing columns from list box?
- From: Douglas J. Steele
- Re: referencing columns from list box?
- From: Pendragon
- Re: referencing columns from list box?
- Prev by Date: Re: referencing columns from list box?
- Next by Date: Re: Wrong Data Type Error for Selected Value of a ComboBox
- Previous by thread: Re: referencing columns from list box?
- Next by thread: Re: referencing columns from list box?
- Index(es):
Relevant Pages
|