Re: Converting Numerical Value to Lookup value

From: SteveS (sanfu_at_techie.com)
Date: 03/07/05


Date: Mon, 07 Mar 2005 00:15:52 -0900

I'm not really sure what you are trying to do but maybe I can get you
started.

Comments inline....

Dan wrote:
> I am using an expression in Forms to take several fields of data and convert
> them to a block of text.
>
> For one of the fields set-up as a combo box, it is based on a Lookup of a
> separate table to text in a specified field. The table of data that is
> looked up has 3 fields/columns: Index [numeric, 1-12], Eng [Month of the
> year in English], Fr [Month of the year in French].
>

You have a combo box (I'll call it cboMonth) with the row source set to
a query or SQL statement that looks something like this:

"Select Index, Eng, Fr From tblEng_Fr_Month Order by Index"

The bound column should be 1 and the column count should be 3.

> When I concatenate the fields into the expression, the field for looking up
> the month (named [FMonth] or [EMonth]) displays as the numeric value of the
> lookup table, not the corresponding French or English value as it does in
> the rest of the form. Rendering this value through a simple statement of
> [FMonth] is sufficient. Deriving the value of does not require use of ! and
> . operators to specifically call on the data from elsewhere in the form.
>

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
from the combo box?

> I've posted this problem on a couple of other forums and received a reply to
> make the following statement:
> MyCombo.Column(1)
>

This syntax is how you reference columns other that the bound column of
a COMBO BOX or LIST BOX. It doesn't apply to text boxes.

"MyCombo" is an example of a combo box name. You need to substitute the
name of your combo box.

> Given this, I have adapted it to [fmonth].column(2) to display the French
> month, for instance (note table structure in second paragraph above).
> However, upon entering this in Expression Builder, the system corrects the
> syntax to [fmonth].[column](2) which results in #Error when displayed.
>
See previous paragraph.

If you want the unbound text box FMonth to display the French name of
the month when a month is selected using the combo box, you would set
the control source of FMonth to = ComboBoxName.Column(2). (Remember,
combo boxes are zero based - the first column is column 0)

If the combo box is named "cboMonth", then the control source for FMonth
would be: =cboMonth.Column(2)
EMonth would be: =cboMonth.Column(1)

> What is the syntax required in expression builder to have a lookup table
> display information from a specified column when the field already
> displaying the information renders a PI of the numeric value from column 0?
>
>

As an example, If the control sources were:

EMonth control source: =cboMonth.Column(1)
FMonth control source: =cboMonth.Column(2)

,in the after update event of the combo box, you could use a message box
to display the translated month name using the unbound text boxes:

Msgbox "Month " & Me.cboMonth & " in English is " & EMonth & " and in
French is " & FMonth & ". "

You don't even need to use the unbound text boxes unless you want to
display the month names! You can just use the combo box:

Msgbox "Month " & Me.cboMonth & " in English is " &
Me.cboMonth.Column(1) & " and in French is " & Me.cboMonth.Column(2) & "."

(The above should be on one line)

***NOTE: change "cboMonth" to the name of your combo box.

HTH

-- 
Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)


Relevant Pages

  • Re: Suppress Label for Blank Data
    ... check boxes the detail does not shrink, leaving the three check boxes one ... and 3 of them are checked, I would only like to display ... Set the Control Source of this text box to something like this: ...
    (microsoft.public.access.reports)
  • Re: Earliest and latest date in a field
    ... > Create 2 text boxes on a form. ... Set the control source of the first box to ... >> date field which contains dates (funny enough). ... >> can display to the user what date range has just been imported. ...
    (microsoft.public.access.forms)
  • Re: How to Display in Forms- Join Table Query ?
    ... How do i get the input from this quries to display on individual text boxes? ... Control Source property identifying a field in the table; ... A Report would instead be based on a Query joining the two tables; ...
    (microsoft.public.access.forms)
  • Re: error 3048 - Cannot open any more databases
    ... The combo that uses the callback function as its RowSourceType will still be able to display the desired data. ... What happens is that you load the static array one, and then it calls the callback function whenever it needs a value. ... I am using these combo boxes not only as a way of selecting a ... > the same subform, just inserted 48 times. ...
    (microsoft.public.access.formscoding)
  • Re: Urgent: Need Shipping Box for Sun 24.1" LCD Display
    ... I made the original posting) and they weren't able to help. ... Luckily there was no damage to the display inside the box. ... be sure to save at least one of these boxes for future shipments. ... You can try a company called Heritage Paper (used to be called ...
    (comp.sys.sun.admin)