Data Access Worldwide Knowledge Base
Article ID 2181 Article Title HOWTO: Find out the fieldnames of a table in a Crystal Reports Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2181 KBase Category VDF11 Date Created 10/27/2005 Last Edit Date 10/27/2005
Article Text
QUESTION:
How do I find out what the fieldnames are of a table used in my Crystal Report?
ANSWER:
You can use the following code:
Boolean bOk bAttached
Handle hoDatabaseTable hoTableFields hoTableField
Variant vFields vField
Integer iFields iField
String sFieldName sFormulaFieldName sTableName
// Assume sTableName contains the value "customer"
Get GetTableObjectByName Of hoReport sTableName To hoDatabaseTable
Move (hoDatabaseTable) to bOk
If (bOk) Begin
// create temporary object for all table fields
Get Create U_cCrystalDatabaseFieldDefinitions to hoTableFields
Get ComFields of hoDatabaseTable To vFields
Set pvComObject of hoTableFields To vFields
Get IsComObjectCreated of hoTableFields to bAttached
If (bAttached) Begin
Get Create U_cCrystalDatabaseFieldDefinition to hoTableField
Get ComCount Of hoTableFields To iFields
For iField From 1 To iFields
Get ComItem Of hoTableFields iField To vField
Set pvComObject Of hoTableField To vField
Get IsComObjectCreated of hoTableField to bAttached
If (bAttached) Begin
// This returns for example "CREDIT_LIMIT"
Get ComDatabaseFieldName Of hoTableField To sFieldName
// This returns for example "{CUSTOMER.CREDIT_LIMIT}"
Get ComName Of hoTableField To sFormulaFieldName
End
Loop
Send Destroy Of hoTableField
End
Send Destroy Of hoTableFields
End
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.