Assigning the Value of a field to a table control name

  • Thread starter Thread starter Geoff P
  • Start date Start date
G

Geoff P

Guest
Hello,
This is probably a dumb question but here it goes:

What I am trying to do is take a truck number which is the value in a field in one table, and use the number to refer to the name of a field in another table. Here is the code I am using:

ControlName = [rec3]![truck #]
rec4.Edit
rec4!([ControlName].Value) = rec3![license name]
rec4.Update
rec4.MoveFirst

using rec4!([ControlName].Value) to refer to the value that has been assigned to control name does not work.

Does anybody know how I can use the value of a variable on one table to refer to a field name on another table?

Any help would be greatly appreciated.

Thanks
Geoff


[This message has been edited by Geoff P (edited 03-15-2001).]
 
I'm not sure what your asking!!

Are you saying that the value of a field in one table is the name of the field in another
e.g. if you have a [Truck #] of 12345 then there is a field in another table called 12345.

Or that you have a control (on a form?) who's name is the same as the value in [Truck #] and that controls value contains the name of the field in the other table?

In your code you assign [Truck #] to ControlName. What is control name (i.e. String, Double, Control, Object etc)???
 
Sorry I was not clear... Yes I am saying that the value of a field in one table is the name of a field in another. I am not using a form at all in this instance. Controlname is assigned as varient.

I have however found the solution to this problem. (Thanks again to Jim Bulger)

The answer is:

ControlName = [rec3]![truck #]
rec4.Edit
rec4.fields(ControlName) = rec3![license name]
rec4.Update
rec4.MoveFirst

Thanks for your input kal-el.

Geoff P
 

Users who are viewing this thread

Back
Top Bottom