Selecting a single field to view on a form


L

Leslie Isaacs

Hello All
I want to allow the user to use a combobox to select one field to view from
the form's underlying table.
The combobox is called [combo0], and in the form's detail section is the
textbox [text0] that I want to display the selected field.
I can do this with a very long Case statement (one Case for each potential
field name selection), like this:
Case "ver k"
[Text0].ControlSource = "=[sarah k]"
Case "ver b"
[Text0].ControlSource = "=[ver b]"
etc
etc

This works but is obviously very tedious. I'm sure I should be able to use
something like:
[Text0].ControlSource = "=[combo0]"
but this just keeps displaying the field name in [text0], not the field
value.

Where am I going wrong?

Hope someone can help.
Many thanks
Leslie Isaacs
 
Ad

Advertisements

Ad

Advertisements

L

Leslie Isaacs

Doug

Brilliant - that works perfectly!!

Many thanks
Les

Douglas J. Steele said:
Try

[Text0].ControlSource = "=[" & combo0 & "]"

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Leslie Isaacs said:
Hello All
I want to allow the user to use a combobox to select one field to view
from the form's underlying table.
The combobox is called [combo0], and in the form's detail section is the
textbox [text0] that I want to display the selected field.
I can do this with a very long Case statement (one Case for each
potential field name selection), like this:
Case "ver k"
[Text0].ControlSource = "=[sarah k]"
Case "ver b"
[Text0].ControlSource = "=[ver b]"
etc
etc

This works but is obviously very tedious. I'm sure I should be able to
use something like:
[Text0].ControlSource = "=[combo0]"
but this just keeps displaying the field name in [text0], not the field
value.

Where am I going wrong?

Hope someone can help.
Many thanks
Leslie Isaacs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top