Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Results differ when exported 1

Status
Not open for further replies.

fredka

Technical User
Jul 25, 2006
114
US
I have a report that uses unbound fields that are assigned at runtime. On open event assigns recordset... Code is below:

For some reason, when I export the report to either word or snapshot viewer, it only shows one month repeated with same data. The report shows rows of month and columns of year.

Any ideas what would cause the report to differ when exported? thanks!!!!

' Create underlying recordset for report using criteria entered in
' EmployeeSalesDialogBox form.

Dim intx As Integer
Dim qdf As QueryDef
Dim frm As Form

' Don't open report if frmOverviewRpts form isn't loaded.
If Not (IsLoaded("mainswitchboard")) Then
Cancel = True
MsgBox "To preview or print this report, you must open " _
& "main switchboard in Form view.", vbExclamation, _
"Must Open Dialog Box"
Exit Sub
End If

' Set database variable to current database.
Set dbsReport = CurrentDb
Set frm = Forms!mainswitchboard
' Open QueryDef object.
Set qdf = dbsReport.QueryDefs("qryHistoricalComparisonYearsFinalB")


' Set parameters for query based on values entered
' in EmployeeSalesDialogBox form.
qdf.Parameters("Forms!mainswitchboard!startDate") _
= frm!startdate
qdf.Parameters("Forms!mainswitchboard!ReportYear") _
= frm!ReportYear
qdf.Parameters("Forms!mainswitchboard!NorC") _
= frm!norc
' Open Recordset object.
Set rstReport = qdf.OpenRecordset()

' Set a variable to hold number of columns in crosstab query.
intcolumncount = rstReport.Fields.Count
 
Can you tell us why you are using a recordset? I think you might be going at something the very hard way but I can't tell for sure since you haven't really provide much background about your data and what you want your report to do.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Sorry about that. This report is a 4 year comparison of data by month. The crosstab query results look like this:

2006 2005 2004 2003
jan 200 320 322 231
feb 220 444 323 251
mar 272 323 522 279
apr 400 323 322 359
may 350 600 309 527

The issue is that the column headings can change. That is the reason I was using the unbound columns on the form. I hope that makes sense. Thanks!!

 
I would use the solution at faq703-5466 with small changes made to switch from months to years.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks Duane. I will work that angle.

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top