GrandMasterTuck
In need of medication
- Local time
- Today, 11:29
- Joined
- May 4, 2013
- Messages
- 129
Hi folks. I always have unique issues, and you guys are champs at helping to solve them. Here's a tough one (at least for me):
I have a query that's fetching records. Works like any other query. In one of my query's columns, I want the recordset to return a value based on a variable column name in the query. For example, let's say I have the following columns and records in the underlying table (on which the query is based):
What I want the recordset in my query to look like is this:
I'm using that DISPLAY field to supply a value to a report, and I want to be able to sort of future-proof this report so that I don't have to hard-code a bunch of IF/THEN statements on that field (the one hosting DISPLAY) so the system knows which value to display. This way, if, in the future, the boss wants a new field added, like HEIGHT (for example), I can then get the report to display the HEIGHT value for any record by switching that record's FETCH value to "HEIGHT", and won't need to open the report in design view and modify the IF/THEN statements, I'll only need to modify the table itself to add the column.
EDIT: I guess I don't necessarily need the query itself to do this, it's fine with me if I can code a field on the report to do it instead. Just need help with the syntax. Again, the FETCH column in that table gives me the NAME of the Column from which I want to fetch the data, and that data is displayed in the DISPLAY column (which is then, in turn, displayed on the report, or instead maybe the field on the report does the 'calculation' to figure out which data to show... either way)
I guess what I'm asking is: what is the proper syntax for a report field's control source so it fetches a value from a different field that has a name that matches the value entered into the FETCH column.
Does that make sense? I hope somebody can help me with this... Thanks!
I have a query that's fetching records. Works like any other query. In one of my query's columns, I want the recordset to return a value based on a variable column name in the query. For example, let's say I have the following columns and records in the underlying table (on which the query is based):
Code:
NAME AGE RACE SEX FETCH
----------------------------------------------
James 18 W M AGE
Bill 19 W M RACE
Amy 20 W F SEX
Don 19 B M NAME
What I want the recordset in my query to look like is this:
Code:
NAME AGE RACE SEX DISPLAY
----------------------------------------------
James 18 W M 18
Bill 19 W M W
Amy 20 W F F
Don 19 B M Don
I'm using that DISPLAY field to supply a value to a report, and I want to be able to sort of future-proof this report so that I don't have to hard-code a bunch of IF/THEN statements on that field (the one hosting DISPLAY) so the system knows which value to display. This way, if, in the future, the boss wants a new field added, like HEIGHT (for example), I can then get the report to display the HEIGHT value for any record by switching that record's FETCH value to "HEIGHT", and won't need to open the report in design view and modify the IF/THEN statements, I'll only need to modify the table itself to add the column.
EDIT: I guess I don't necessarily need the query itself to do this, it's fine with me if I can code a field on the report to do it instead. Just need help with the syntax. Again, the FETCH column in that table gives me the NAME of the Column from which I want to fetch the data, and that data is displayed in the DISPLAY column (which is then, in turn, displayed on the report, or instead maybe the field on the report does the 'calculation' to figure out which data to show... either way)
I guess what I'm asking is: what is the proper syntax for a report field's control source so it fetches a value from a different field that has a name that matches the value entered into the FETCH column.
Does that make sense? I hope somebody can help me with this... Thanks!
Last edited: