If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Setting Recordsource in report
Hi!
I've designed a form that allows you to set the recordsource of a report based on criteria that you select in combo boxes on the form. I have set 'specreport' as the report as below but when I come to changing the record source of the report I get a C++ error- abnormal program termination! Can anyone help!!? dim scecreport as Report Set specreport = Report_Summary_report specreport.RecordSource = wherestring |
#2
|
|||
|
|||
Setting Recordsource in report
Several issues.
1. You may have more success using: DoCmd.OpenReport "Summary_report", acViewPreview, , wherestring If you want to use your approach try: Dim specreport As New Report 2. Assigning the RecordSource of the report after you open it is not likely to work. Instead: - Save the report without any RecordSource. - Assign the SQL statement to a global string variable before opening the report. - Use the Open event of the report to read the string, and assign it to the RecordSource property. 3. If you reassign the RecordSource of a form or report, be *very* careful that fields do not disappear or change data type. Access only evaluates the presence of the field and its data type when you originally open. It the new RecordSource lacks the field, it can crash. Or if Access thought the field was a number, but it turns out to be text, it can also crash. This is especially important with calculated fields, where the data type is not defined in the table. JET is notorious for getting it wrong, so it is best to typecast in the query as described in article: Calculated fields misinterpreted at: http://allenbrowne.com/ser-45.html -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Vikki" wrote in message ... I've designed a form that allows you to set the recordsource of a report based on criteria that you select in combo boxes on the form. I have set 'specreport' as the report as below but when I come to changing the record source of the report I get a C++ error- abnormal program termination! Can anyone help!!? dim scecreport as Report Set specreport = Report_Summary_report specreport.RecordSource = wherestring |
#3
|
|||
|
|||
Setting Recordsource in report
Thanks Allen, that's ace. -----Original Message----- Several issues. 1. You may have more success using: DoCmd.OpenReport "Summary_report", acViewPreview, , wherestring If you want to use your approach try: Dim specreport As New Report 2. Assigning the RecordSource of the report after you open it is not likely to work. Instead: - Save the report without any RecordSource. - Assign the SQL statement to a global string variable before opening the report. - Use the Open event of the report to read the string, and assign it to the RecordSource property. 3. If you reassign the RecordSource of a form or report, be *very* careful that fields do not disappear or change data type. Access only evaluates the presence of the field and its data type when you originally open. It the new RecordSource lacks the field, it can crash. Or if Access thought the field was a number, but it turns out to be text, it can also crash. This is especially important with calculated fields, where the data type is not defined in the table. JET is notorious for getting it wrong, so it is best to typecast in the query as described in article: Calculated fields misinterpreted at: http://allenbrowne.com/ser-45.html -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Vikki" wrote in message ... I've designed a form that allows you to set the recordsource of a report based on criteria that you select in combo boxes on the form. I have set 'specreport' as the report as below but when I come to changing the record source of the report I get a C++ error- abnormal program termination! Can anyone help!!? dim scecreport as Report Set specreport = Report_Summary_report specreport.RecordSource = wherestring . |
Thread Tools | |
Display Modes | |
|
|