Link DatabaseFieldName and Field Heading


I have a Crystal Report which the user wants to the able to dynamically sort based on the Field Heading in the report. I have some VBA code which iterates throught the Field Headings on the page heading section of the report and displays them in a combobox to allow the user to select one. The code looks something like:

cboOrderBy.AddItem objCRRpt.Sections(2).ReportObjects.Item(i).Text

I was then going to pass this name to the report on loading to sort the data using something like:

objCRRpt.RecordSortFields.Add objCRRpt.Database.Tables(1).Fields(3), crAscendingOrder

The problem is that the customer wanted the field headings renamed to more meaningful names (to them) than the actual Database Field Names.
This means the field heading names in the report and data base field names no longer "match up". Is there a way to cross reference one against the other in code so the I can display the Field Headings as shown on the report while under the bonnet passing the actual database field name this Field Heading refers to?

Thanks in advance.
Who is Participating?
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.

The field heading is just a text box. While if you delete the detail line the header disappears, you can still edit the headings at any time. You can rename without any issue because I believe your code is based off the column coming from the database and not the text box.

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
jguerin2Author Commented:
Thanks wykabryan,

The database field names and the field heading names (text boxes) on the reports are different. (as I want).

When presenting the user with the choices for sorting from my VBA form I need to show the Report Field Heading Names (as displayed in the text boxes  - which I get from the Report.Sections(2).ReportObjects.Item(i).Text) while the Stored Procedure underneath must use the Database Field Names.

Is there a class or library that allows me to cross reference these two in code? i.e. when I choose a Field Heading Name I use it to reference the actual database field name it refers to?

I am not sure if there is a class or library to be honest with you.

why dont you create a view in the database. This will allow you to rename the columns without having to touch the tables. Then do a set database location and point the report from the table to the report. Then your users get what they want and you dont have to fuss around with the code..
jguerin2Author Commented:
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
Crystal Reports

From novice to tech pro — start learning today.