• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

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.
  • 2
  • 2
2 Solutions
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.
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:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now