How to Use DBC Field Captions on Visual FoxPro Forms & ReportsLast reviewed: October 5, 1995Article ID: Q137626 |
The information in this article applies to:
SUMMARYThe Database Container allows you to enter captions for the fields of a table. However, there is no FieldCaption control that you can place on a form to display a field's caption or to automatically update a field's label on the form should you choose to change the field's caption in the database header. The examples in this article show you how to use DBGETPROP to create a link between field labels on a form and the field captions in the database so that changes propagate.
MORE INFORMATION
Example One: Setting the Label for a Standard Text Box Field
Example Two: Setting Headings of a GridNormally, a grid with a ColumnCount of -1 will use the Caption property to detrmine the headings used for columns. However, if you specify the number of columns, the headings are determined by the Caption of the header object, not by the Caption property of the ControlSource field. The following code placed in a grid's Init event will set the grid headings when an instance of the grid is created:
LOCAL iLoop, iMax, cSource SET DATABASE TO <<insert databasename here>> WITH This && Determine Number of Columns in Grid iMax = .ColumnCount && Get the Table Name used by the Grid && This is necessary because unlike a text box control, && the ControlSource property of a column does not preface && the field name with the table name, so the code must && do this manually. Note that "." is included. cSource = .RecordSource + "." && Loop through each column FOR iLoop = 1 TO iMax WITH .Columns(iLoop) && Set Header Caption .Header1.Caption = ; DBGETPROP( cSource + .ControlSource, ; "FIELD", "CAPTION" ) ENDWITH NEXT iLoop ENDWITH Example Three: Using Captions in Report HeadersTo use field captions in reports, create a field (not a text label) whose expression is DBGETPROP("tablename.fieldname","FIELD","CAPTION"). NOTE: Here tablename.fieldname is the actual name of the table and field. When the report runs, the expression will evaluate to the proper caption.
REFERENCESFor additional information, please see the Visual FoxPro Help file, the Developer's Guide, and the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q130997 TITLE : How to Use the Caption Fields of a Table in a Form |
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |