How get last two characters from a field name in a new field via a query

I have a query that has a field named "F1-16".  In the query I want to add an expression that gets the characters AFTER the hyphen and then that expression is the result of the query field.

So if the query has a field named "F1-16", I want a separate field named "Number to have a result of 16 in it.

Kind of like:

I sure hope this makes sense.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
You can use the following to do what you are looking for...


Open in new window

SteveL13Author Commented:
No.  I want the right two characters of the field NAME to be the result.  Not the right two characters of the field value.
That isn't how queries work.  Queries work on sets of data.  They do not expose objects.

The fact that you are asking this question leads me to believe that you have a spreadsheet rather than a table.  Columns are not added on the fly to relational tables.  And column names in relational tables don't contain data as they frequently do with spreadsheets.  For example, in a relational table, you would never have a column named MarchAmt.  Or even worse, MarchElectricAmt.  "March" is data and should be derived from a date field so instead of having 12 columns, one for each month, you would have 12 rows.  The second example is even worse since it implies 2 repeating groups, months AND expense types.

If you tell us more about what you are doing we might be able to suggest a way to normalize the schema so you have what you need in the data itself.
Gustav BrockCIOCommented:
You could (would have to) open the table as a recordset in VBA. Then loop through the fields catching the field names and, from these, build the SQL bit by bit.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.