Re: referencing columns from list box?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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!)






.



Relevant Pages

  • Re: referencing columns from list box?
    ... Is there a way to get Me.MyTextbox to display Corporate, ... but I was curious if there was a way to reference ... The control source is Forest. ... The normal approach is to put code in the combo box's AfterUpdate event: ...
    (microsoft.public.access.formscoding)
  • RE: How to Reference a Property in a Linked Library - I think
    ... Just getting the XY Scatter chart to display properly was a near ... I have only used the Object Browser for the standard reference ... and do not know how to reference additional libraries ...
    (microsoft.public.access.modulesdaovba)
  • Re: Converting Numerical Value to Lookup value
    ... Are FMonth and EMonth unbound text boxes on the form that you want to ... display the French/English names of the months when a month is selected ... It doesn't apply to text boxes. ... If the combo box is named "cboMonth", then the control source for FMonth ...
    (microsoft.public.access.forms)
  • RE: Making one field on a form dependent on another fields results
    ... use an AutoNumber field type for the primary key. ... If your customer changes their name or address, ... > ColumnWidths How much horizontal space to allow for display of the column. ... > textbox with its control source set to the Position field. ...
    (microsoft.public.access.forms)
  • Re: Are you as polite and diplomatic as COBOL?...
    ... The "balloon" approach might be a good option for some, ... Just do a quick reference in the N/E help file on those ... > decimals or without decimals. ... > enter 1234 and I display 1.234 ...
    (comp.lang.cobol)