Question

I Have a Query Displaying a Result, Need to Find a Value of one of these Columns in that Query by it's Field Name.

The query is Displaying all the fields in a table (Along with other fields from other tables) using The ([Table name].*) (cause it has too many fields) in the query builder. So if it possible to add a criteria under this one that would be helpful, but I'm also welcome any other suggestions

Edit:

I didn't post my problem clearly, here is the situation: Table "Default Payments" It has a Name field and a 60 other fields named like : 1/1/2013, 1/2/2013 ... 1/12/2017 Under each field of them the payment that should be paid in that date.

now my report should display the real payment from another table and the default payment depending on a date given to it like the fields names for example let's say 1/10/2015.

the query should find the field that is named like 1/10/2015 and give me it's value. ( the search is filtered based on the name and that date so the query display only one row with one value under that field).

the answers are all depend on knowing the field name but it will not be hard coded in the query, it will be given to it.

Was it helpful?

Solution 4

Ok, i think i was over thinking in this problem, here is a way if any one faced something like it.

The problem was providing the field name which was changing, but i forgot to say it was calculated using the DateSerial function to get the first day of a date.

And Instead of searching in a query, i searched in the main table directly using Dlookup function. The field name prosperity of that function is using the date serial to get the column name, and the the table name and finally the criteria, which is the client name that is provided to the report and it gave the right value i needed.

Thanks all for your efforts.

OTHER TIPS

Of course it's possible. MS Access uses SQL. Please have a look at this example page.

Just use this query...Is this what you want?

SELECT FieldName1,FieldName2
FROM TableName
WHERE FieldName1='Whatever';

Just select whatever field names you have, from just 1 to every field name.

Yes, I understand using a query that selects "Table.*" to select all fields, but if you want to filter on one of the fields, just go to query builder, double click on the table field so it is added, then UNCHECK the "Show" checkbox and add your criteria. Results will look like:

SELECT Table1.*
FROM Table1
WHERE (((Table1.FldA)="A1"));

If you don't uncheck "Show", no harm, but when the query runs, it will generate a name for the field like 'Field0'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top