
Using Crystal 8.5 and VB6 -- need to get a list of fields available to the report
Hi,
I've written a front-end to Crystal 8.5 using VB6. At one point it allows
the user to select fields to be used in the record selection formula.
Currently the list of fields the user can select from is generated by
looping through the report fields and selecting the ones that are in the
database and are also present in the detail section of the report. Here is
the looping code:
'Add only the detail fields that are on the report to the arrays.
ReDim asReportFields(0)
ReDim aiReportFieldTypes(0)
For iCount = 1 To oMWReport.moCRReport.Sections("D").ReportObjects.Count
'Always clear previous references to avoid orphaned objects.
Set goCRReportObj = Nothing
Set goCRReportObj =
oMWReport.moCRReport.Sections("D").ReportObjects(iCount)
If goCRReportObj.Kind = crFieldObject Then
Set goCRFieldObj = Nothing
Set goCRFieldObj = goCRReportObj
If goCRFieldObj.Field.Kind = crDatabaseField Then
Set goCRFieldDef = Nothing
Set goCRFieldDef = goCRFieldObj.Field
ReDim Preserve asReportFields(UBound(asReportFields) + 1)
ReDim Preserve aiReportFieldTypes(UBound(aiReportFieldTypes)
+ 1)
asReportFields(UBound(asReportFields)) = goCRFieldDef.Name
aiReportFieldTypes(UBound(aiReportFieldTypes)) =
goCRFieldDef.ValueType
End If
End If
Next
What I'm looking for is something similar to the above code, but that does
not limit the fields to those in the detail section of the report. Nor does
it just grab all fields in the database. I'd like to get the fields from
the database and be able to tell what fields are key fields that point to
other tables, etc. and then get all the fields from all the linked tables.
So does anyone out there know how to tell if a field is a key field to
another table?
Thanks,
Andy