INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Text Box Value - to Be Field Name in Reports Recordsource

Text Box Value - to Be Field Name in Reports Recordsource

(OP)
How can I get the value of a text box (on a form) to be the field name in a query for a reports record source - at run time?
The text box value will equal a field name that is in a table that is used in the query to build the reports record source.

I'm trying to build it to where the user does not have to go into design view of the query and manually pick the needed field each time the report is generated....

Any suggestions or examples would be much appreciated..!!!
Thanks in advance..!
air1access

RE: Text Box Value - to Be Field Name in Reports Recordsource

I would use a combo box, list box, or option group for the user to select the field. For instance
  1. First Name
  2. Last Name
  3. City
  4. Region
Assuming your form is named [frmRptSelect] and your option group is [grpField] your query would have a column defined as:

SelectedField: Choose(Forms!frmRptSelect!grpField,[FirstName], [LastName], [City], [State])

Your report can then have a text box bound to [SelectedField] showing the value of the field selected by the user.

Duane
Hook'D on Access
MS Access MVP

RE: Text Box Value - to Be Field Name in Reports Recordsource

(OP)
Thanks for the response dhookum..!

I'm not keen to the Choose Function. Never used it before...

I have a "global variable" that is set when the use clicks a command button to run the report...
The variable is set off of a value in a text box... Can I use this variable in the Choose Function..?

I'm trying to figure out how I can use an option group but I'm stumped....!

Thanks for your help..!

RE: Text Box Value - to Be Field Name in Reports Recordsource

(OP)
I tried -
Matrix: Choose(1,getglobal('GBLCurrentMonth'))

Alls it does is put "Sept-2015" for the entire recordset in the Matrix column.

There is a field named "Sept-2015" in one of the tables that is used for the query.
I need the value of that field (Sept-2015) in the query....

RE: Text Box Value - to Be Field Name in Reports Recordsource

I doubt your solution will work. Can you provide any of the information that I guessed at? What don't you understand? Do you have an option group or other control to select a field? What does your query SQL look like?

Duane
Hook'D on Access
MS Access MVP

RE: Text Box Value - to Be Field Name in Reports Recordsource

(OP)
Ok - As I was....!!

I figured it out.
After doing some research - I learned more about the Choose Function....
I applied your suggestion, and BAM..!! It does exactly what I was wanting... A different approach then I was thinking, but none the less - I learned something new..
And it works..

Thank you so much dhookom...!!!
You rock..!!!

air1access

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close