I'm going crazy trying to figure this one out...
I've got a form that allows the user to change the sort order of the data in a list box (dynamically changes SQL 'Order By'). There's a Print button on the form with the following code:
So the report runs from the query. I can change the sort order in the query and run both the query and report separately with no problem. When I click on the Print button, the report runs with no problem EXCEPT when the Order By includes a calculated aliased field:
which results in a "Enter parameter value" dialog. If I click OK, the report runs with no error.
I'm afraid I'm going to see this again with the other calculated fields when the users get around to entering some data for them!
I looked at other "parameter prompt" posts, but couldn't find anything that seemed to address this.
Any ideas?
Oh, yeah; here's the contents of qryRptFlash:
< M!ke >
I've got a form that allows the user to change the sort order of the data in a list box (dynamically changes SQL 'Order By'). There's a Print button on the form with the following code:
Code:
Private Sub cmdPrint_Click()
Dim sSQL As String
Dim db As Database
Dim qd As QueryDef
'--since user can change sort on the fly,
'--get the current version of the SQL statement:
sSQL = lstSales.RowSource
'--crack open the database:
Set db = CurrentDb()
'--assign new SQL value to the query:
Set qd = db.QueryDefs("qryRptFlash")
qd.Sql = sSQL
'--clean up:
qd.Close
Set qd = Nothing
db.Close
Set db = Nothing
'--NOTE: the report uses these fields (bound):
lblSortedBy.Caption = "Sorted by: " & msSortedBy
lblDateRange.Caption = msDateRange
'--run the report:
DoCmd.OpenReport "rptFlash", acViewPreview, "qryRptFlash"
End Sub
Code:
SoldDate-ContactDate
I'm afraid I'm going to see this again with the other calculated fields when the users get around to entering some data for them!
I looked at other "parameter prompt" posts, but couldn't find anything that seemed to address this.
Any ideas?
Oh, yeah; here's the contents of qryRptFlash:
Code:
SELECT ContactDate, SoldDate, SoldDate-ContactDate AS [Diff in Days],
ProposalAmount, BudgetEstimator AS [Estimated Amount],
ProposalAmount-BudgetEstimator AS [Diff in $],
(ProposalAmount-BudgetEstimator)/ProposalAmount AS [Diff in %],
Channel, Employs, Region, Opportunity, Product, PM, Segment, SubSegment
FROM tblMaster
WHERE SoldDate BETWEEN #02/01/2004# AND #02/19/2004#
ORDER BY SoldDate-ContactDate;
< M!ke >