Data Access Worldwide Knowledge Base
Article ID 2198 Article Title PROBLEM: When I run my CDO based reports the error date fields are unmapped pops up Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2198 KBase Category VDF11 Date Created 12/19/2005 Last Edit Date 02/27/2009
Article Text
PROBLEM:
When I run our report, the Crystal Report viewer comes up with the message that the date-fields are unmapped. Why is that?
ANSWER:
The data for CDO is placed in a variant array. Fields marked up as DATE fields in the TTX (Record description) are stored as DateTime members in the variant array. Crystal expects Date values. There is a property of the Report object named "ConvertDateTimeType". The Crystal documentation says: "Gets or sets the report option that specifies the format to be converted for date/time fields."
With the instruction:
Set ComConvertDateTimeType Of hoReport To crConvertDateTimeToDate
Crystal is told to convert the datetime types to dates.
Most logical place to add the above line of code is in the OnInitializeReport procedure. However, when the path to the TTX file(s) used in the report at design time is not the same as the deployment's path, Crystal will pop up a dialog so you can fix the path to the TTX.
If you want/need to set this property, use the following code:
Function OpenReport Returns Boolean
Boolean bOk
Handle hoReport
Forward Get OpenReport To bOk
If (bOk) Begin
Get ReportObject To hoReport
If (hoReport <> 0) Begin
Send ComDiscardSavedData Of hoReport
Set ComConvertDateTimeType Of hoReport To crConvertDateTimeToDate
End
End
Function_Return bOk
End_Function // OpenReport
As you can see, I also set the property to discard saved data in case you had that option turned on by default in Crystal Reports. If you have saved data (or the TTX file cannot be found), Crystal will not use your CDO data array but the default data from the TTX file(s), which means only one record is printed.
The above information is partially discovered by Roel Westhoff and can be found back in the Data Access forums (date around november 6th 2005).
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Web Links Related to this Article
DAW Knowledge Base article 2185: HOWTO: Create TTX Files using Crystal Reports Designer
URL=http://www.dataaccess.com/KBPrint.asp?ArticleID=2185
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.