View Single Post
  #2  
Old April 4th, 2008, 05:00 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default Parameter Prompt Annoyingly Appears (sometimes)

Try running the report's query on its own.
Does it ask for the parameter?
YES: Then problem is in the query.
a) Is the field really called SalesRep?
Or is it different, e.g. [Sales Rep]
b) Anything in the query's Filter or Order By properties?
(Properties box in query design.)

NO: Then problem is in the report.
a) Open the rpeort in design view, and clear its Filter and OrderBy
properties.
b) Look for controls that refer to the field wrongly (e.g. with the space.)
c) Look in the Sorting And Grouping box, to see if the field is wrong there.
d) If other fields on the report refer to SalesRep, but there is no text box
named SalesRep, try adding a text box with that name and bound to that
field. (Sometimes the Access report optimizer tries to be too clever.)

If you are still stuck, after opening the report, open the Immediate Window
(Ctrl+G), and ask it what the report's filter is, e.g.:
? Reports![Report1].Filter

--
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.

"JeffP-" wrote in message
...
I have a form that I set the SQL query to either

if len(sParam) = 0 then
sSQL = "Year=2007"
Works fine I get all records for that year

If len(sParam) 0 then
sSQL = "Year=2007" & " and " & sParam
(value= "Year=2007 and salesrep = 'RosieS'")

Now I'm prompted to enter a parameter for salesrep - where does that come
from?

My report has a query that returns all records - no parameters or other
criteria.

Query... only criteria is that the job ID's exist...

SELECT [Main Job Log].[Job #], [T_Year].[Year] AS [Year], [Main Job
Log].[Owner], [Main Job Log].[Name], [Main Job Log].[City], [Main Job
Log].[Manufacturer], [Main Job Log].[RoofSystem], [Main Job Log].[SqFt],
[Main Job Log].[SalesRep], [T_Year].[Year]
FROM [Main Job Log] INNER JOIN T_Year ON ([Main Job Log].[Job
#]=[T_Year].[IDEnd]) AND ([Main Job Log].[Job #]=[T_Year].[IDStart])
ORDER BY [Main Job Log].[Job #];
...end query

..frmReport snipit....
sReportName = sRptName
sWhereFieldName = Me.lbl_WhereFieldName.Caption
sWhereFieldValue = Me.cbo_RptOptionList.Value

If Me.cbo_Year.Visible = True Then
sYear = "Year=" & Me.cbo_Year.Value
Else: sYear = ""
End If

If Me.cbo_RptOptionList.Value = "_All" Then
sWhere = ""
Else:
sWhere = sWhereFieldName & " = '" & sWhereFieldValue & "'"
End If

Select Case Len(Left(sYear, 1)) + Len(Left(sWhere, 2))
Case 3
sQry = sYear & " and " & sWhere
Case 2
sQry = sWhere
Case 1
sQry = sYear
Case 0
sQry = sWhere
End Select

DoCmd.OpenReport sReportName, acViewPreview, , sQry
...end snipit....