Connecting Tech Pros Worldwide Forums | Help | Site Map

Display two fields by selecting value in one

klawiter@nd.edu
Guest
 
Posts: n/a
#1: Nov 13 '05
Greetings,

I have a table with two columns. On my form, I have a combo field that
displays the contents of the first column. Upon selecting an item in
this combo field, I would like to then display the corresponding value
of the second column in a read-only field. I tried to use Expression
Builder in the Control Source for the second field, but no matter what
I try, I get #Name? results.

Can anyone tell me how to make this type of situation work?

Thank you for your time.

Br@dley
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Display two fields by selecting value in one


klawiter@nd.edu wrote:[color=blue]
> Greetings,
>
> I have a table with two columns. On my form, I have a combo field that
> displays the contents of the first column. Upon selecting an item in
> this combo field, I would like to then display the corresponding value
> of the second column in a read-only field. I tried to use Expression
> Builder in the Control Source for the second field, but no matter what
> I try, I get #Name? results.
>
> Can anyone tell me how to make this type of situation work?
>
> Thank you for your time.[/color]

Create a text field and set it's controlsource as...

=[MyComboBox].Column(1)

Change the value of the column number to suit the one you want. Note:
column numbers start at zero.
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response


klawiter@nd.edu
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Display two fields by selecting value in one


Br@dley wrote:[color=blue]
>
> Create a text field and set it's controlsource as...
>
> =[MyComboBox].Column(1)
>
> Change the value of the column number to suit the one you want. Note:
> column numbers start at zero.
> --[/color]

Thank you for taking the time to reply. I believe I understand what
is going on here now. You use the query that populates the combo box
to also pull the data for this field. I did that by altering the query
code in the Row Source for the combo box. Then, I set the Column
Widths to 0";1";0" and increased the Column Count to 3. (The table
that Im referencing actually has a RecordID column as the first column,
so I have been doing this type of thing right along... but didnt
realize it. I bound to column 1.)

I then placed your suggestion in the Control Source for the text field.
Unfortunately, I get the same error.

I did receive another private email with the suggestion that I put code
in the AfterUpdate event of the combo box and push the value to the
field. Essentially, it the same code. Now, that works! The only
problem is that when you move off the record, the field is still
populated. I have to include some code to constantly set it the the
right value for the current record.

Any idea why that would be? At any rate, it appears that I have this
issue resolved. Thanks again for your efforts.

Br@dley
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Display two fields by selecting value in one


klawiter@nd.edu wrote:[color=blue]
> Br@dley wrote:[color=green]
>>
>> Create a text field and set it's controlsource as...
>>
>> =[MyComboBox].Column(1)
>>
>> Change the value of the column number to suit the one you want. Note:
>> column numbers start at zero.
>> --[/color]
>
> Thank you for taking the time to reply. I believe I understand what
> is going on here now. You use the query that populates the combo box
> to also pull the data for this field. I did that by altering the
> query code in the Row Source for the combo box. Then, I set the
> Column Widths to 0";1";0" and increased the Column Count to 3. (The
> table that Im referencing actually has a RecordID column as the first
> column, so I have been doing this type of thing right along... but
> didnt realize it. I bound to column 1.)
>
> I then placed your suggestion in the Control Source for the text
> field. Unfortunately, I get the same error.
>
> I did receive another private email with the suggestion that I put
> code in the AfterUpdate event of the combo box and push the value to
> the field. Essentially, it the same code. Now, that works! The only
> problem is that when you move off the record, the field is still
> populated. I have to include some code to constantly set it the the
> right value for the current record.
>
> Any idea why that would be? At any rate, it appears that I have this
> issue resolved. Thanks again for your efforts.[/color]

Yeah, an AfterUpdate solution works well too...

Put some code on the OnCurrent event of the form to set the value when a
record is first loaded (perhaps to clear your text box).
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response


Closed Thread