Using a field value to reference a field name

This seems simple but I can't figure it out.  I would to use the value from Field1 to reference another field on the form.

For example.

FieldA  FieldB  FieldC

Field1 will be a combo box where you can select one of the fields above

So lets say the value for Field1 is "FieldB"

I want to basically set me.field2 = me.(value of field1 which is "FieldB")

I hope that makes sense??

rtmc_jnealAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Maybe you mean this

Me.Field2 = Me(Me.Combo)

Which says Me.Field2 = Me("FieldB")

?

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:

 Me(Me.Combo)=Me.Field1

 which says - if Field2 is selected from the combo

Me("Field2") - Me.Field1

mx
0
 
mbizupCommented:
Are you trying to dynamically set the controlsource property according to what is selected in the combo?

ie: Change the field a control is bound to based on the combo selection?

You could use this in the After Update event of your combo box:


Me.YourTextboxOrWhatever.ControlSource = Me.YourCombo
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
So, when you select say FieldB from the Combo, what exactly do you want to happen ?

mx
0
 
rtmc_jnealAuthor Commented:
Basically I have 4 different fields that contain prices.  I'm using the value of the combo box to determine which field to pull the price from.
0
 
rtmc_jnealAuthor Commented:
DatabaseMX got it.  Thanks so much.  Figured it was simple.
0
 
mbizupCommented:
The code that I posted earlier should do the trick... what you are describing involves changing the Controlsource property of the textbox.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome.  Wasn't quite sure what you were after.

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.