using an entry in a field as the name of the field

lala

Registered User.
Local time
Today, 13:52
Joined
Mar 20, 2002
Messages
741
this is probably not possible but never know

i have a field in which i store names of fields used for the record's calculations.

for example,

Code:
ID     CalcFIeld               Percentage
1      LCTtlAmount           5
2      LCAmdAMount           4
3      LCTtlAmount           3

the entries in the CalcField field are names of field whose values should be multiplied by the record's % to get the total.

how do i use that field in a query? i'd love it if it was possible to do something like this.


Code:
[percentage]*"[" & calcfield] & "]"

and for the record #1 the program will read it as

Code:
[percentage]*[LCTtlAmount]







you get the idea?


thank you!!!!
 
Possible. You need to use DLookups. This is what your code would look like:

Code:
FieldPercent: DLookUp([CalcFIeld],"NameOfSourceWithField")*[Percentage]

Be sure to replace "NameOfSourceWithField" with the name of the table that has CalcFIeld in it. Also, if NameOfSourceWithField has multiple records there's no telling which record its going to pull in when it does the DLookup. For that you would need to add criteria onto your Dlookup.
 
damn, and i tried dlookups, just not this way

thank you so much!!!! will try and post back
 
this is amazing, t hank you so much!!!!!!!!!!!!!
 

Users who are viewing this thread

Back
Top Bottom