A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Setting Recordsource in report



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2004, 09:50 AM
Vikki
external usenet poster
 
Posts: n/a
Default 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  
Old May 18th, 2004, 10:52 AM
Allen Browne
external usenet poster
 
Posts: n/a
Default 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  
Old May 18th, 2004, 11:25 AM
Vikki
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.