cancel
Showing results for 
Search instead for 
Did you mean: 

Links removed when connecting with the RDC (Automatic SetLocation)

Former Member
0 Kudos

Hello,

We have a VB6 application that is using the Crystal Report 11 RDC to display reports. When we are connecting the report to the database, one of the SQL links is removed because a field contained in this link is removed from its table. This behaviour gives us problem because the data returned is not good anymore. We would have expected the report to leave the SQL intact and give an error instead.

Is there a way to workaround this behavior.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Couple of things:

1) What does the report do in the CR designer hen you remove this object from the database? What ever the designer does, we'd expect at runtime.

2) See if adding the option verify on first refresh helps. You will find this option in the CR designer under the File menu | report Options.

Ludek

Former Member
0 Kudos

Hello,

In the CR Designer, when i do a Set Location the designer will ask me to do a match for the missing fields that will then be used for the link. If nothing make sense you can push the Ok button that will removed the links or the push the Cancel button so the links remain there even if it does not work anymore.

The verify on first refresh make no difference.

Any other question or advice?

Thank you.

former_member183750
Active Contributor
0 Kudos

OK. So from your description, you have essentially the same issue in the designer and at runtime. The "match for the missing fields" is the field mapping dialog. Now, the designer is nice enough to prompt you with a request to tell it what you want to do with the missing field. Runtime is not. E.G.; you designed the report with a particular field and so the report expects that field to be there. if it's not, it has no idea what to do.

You can force the field mapping dialog at runtime, but you will have to code for it as follows:

**

' Purpose: Demonstrate how to manipulate Field Mapping

'

' Field mapping allows the user to change the name of

' a database field that a report field points to if

' that field no longer exists or has been renamed in

' the data source.

'

' In this sample, the Report_FieldMapping event in the

' code for CrystalReport1 is used to programmatically

' change the mapping of the report fields to a different

' database field.

'

Option Explicit

Dim crApplication As New CRAXDRT.Application

Dim WithEvents m_Report As CRAXDRT.Report

Attribute m_Report.VB_VarHelpID = -1

Dim ReportDB As Database

Dim MappingData As CRAXDRT.FieldMappingData

Dim dbMappingData As CRAXDRT.FieldMappingData

Private Sub CRViewer11_CloseButtonClicked(UseDefault As Boolean)

End Sub

' *

' Load the Report in the viewer and enable fieldmapping

'

Private Sub Form_Load()

Set m_Report = crApplication.OpenReport(App.Path & "\FieldMapping.rpt";)

Set ReportDB = m_Report.Database

' Explanation of FieldMappingType:

' 0 - crAutoFieldMapping - Remove all report fields which do not have the same

' name in the new database

' 1 - crPromptFieldMapping - Display a dialog box to get the user to manually

' map the fields

' 2 - crEventFieldMapping - Cause the Report_FieldMapping event to be triggered

'

m_Report.FieldMappingType = crEventFieldMapping

' Verifying the database or using SetLocation will trigger the Field Mapping event

'ReportDB.Verify

' Display our report in the viewer

CRViewer11.ReportSource = m_Report

CRViewer11.ViewReport

End Sub

' **

Private Sub cmdAbout_Click()

frmAbout.Show vbModal

End Sub

' **

Private Sub cmdExit_Click()

Unload Me

End Sub

Private Sub m_Report_FieldMapping(reportFieldArray As Variant, ByVal databaseFieldArray As Variant, UseDefault As Boolean)

' Setting useDefault to True will cancel all fieldmapping

UseDefault = False

' Get the first field in the report ("LastName")

Set MappingData = reportFieldArray(0)

' Setting MappingToFieldIndex to -1 will remove this field from the report

' Set the db field to point to the second database field in the report,

' which happens to be "Last Name"

MappingData.MappingToFieldIndex = 2

MsgBox "Mapped '" & MappingData.FieldName & "' ", vbInformation

' Get the first field in the report ("Total Salary")

Set MappingData = reportFieldArray(3)

Set dbMappingData = databaseFieldArray(12)

' Set the db field to point to the ninth database field in the report,

' which corresponds to "Salary"

MappingData.MappingToFieldIndex = 12

MsgBox "Mapped '" & dbMappingData.FieldName & "' ", vbInformation

End Sub

Ludek

Former Member
0 Kudos

Hello,

Ludek thanks for the information. So far I think i will be able to use the Field Mapping event to trap that there is a unrecognized fields in the report.

Thank you.

Answers (0)