Value as field name

ajarrell

Registered User.
Local time
Today, 13:52
Joined
Feb 4, 2014
Messages
56
Is it possible in Access to use an input value (text) as a field name? I want to access a field based on what the user enters.

Thank you.
 
No you dont. Fields are in tables or querie, and that is no go area for users. In a form you have controls. You knwowhich are available so you can offer user a combobox to pick from. Typing makes no sense.

Forms!MyForm.controls(MyControlName)
 
I have tables of values for each month and need to print the current month value and the YTD total. I thought I could have the user enter which month the report is for so that I could access that data. The month name abbreviation is the field name.

I see your point, though. That would be a good way to fail.

I have gone back and forth (and back and forth) about the structure of my database, and my head is spinning. I was just thinking of posting here about that.
 
Yeah, the date/time dimension of your data should be a value in a field, not the name of a field. In a database you want to search for rows using the value of the data in those rows. You do not want to search for columns, by name, using data as the criteria.
 
Ok. In a form and in a report, I want to replicate a spreadsheet with months as columns and rows as categories of data. Is it possible to display/print month details horizontally? (I only use Access, not VBA.

Thanks.
 
Look into crosstab queries - they do what you're asking.

For example, given a query consisting of month, sales associate, and monthly sales, you can use a crosstab to have months across the top, sales associates down, and their monthly sales as the data.
 
you can use a dlookup for a single value

this syntax. you can include variables within the strings
dlookup("value/column you want" ,"table you want", "how to identify the table row you want")

there are other domain functions, that can count or sum a domain in a similar way. Or you can develop a query with a variable parameter, and bind a form to the query.

It's all a similar idea really.
 

Users who are viewing this thread

Back
Top Bottom