View Single Post
  #3  
Old April 4th, 2008, 07:01 AM posted to microsoft.public.access.reports
JeffP->
external usenet poster
 
Posts: 29
Default Parameter Prompt Annoyingly Appears (sometimes)

Thanks for your reply, see my inline... I may post a followup as to my
solution or continued horrors....

"Allen Browne" wrote:

Try running the report's query on its own.
Does it ask for the parameter?

No, it quickly opens the entire table; note that if I choose my date as year
and the _All, then the where is only ..."where year=2007" and I'm not promted
the report runs and returns all the data for 2007, it's only when I add to
the where as, ..."where year=2007 and SalesRep = 'RosieS'" that I'm now
promted, the same if I choose manufacturer or any other field.

YES: Then problem is in the query.
a) Is the field really called SalesRep?

No, as you can see from the query it's SalesRep, as noted manufacture has
the same result, prompt to enter a parameter dialog, and of course the report
fails to run.

Or is it different, e.g. [Sales Rep]
b) Anything in the query's Filter or Order By properties?

None, there is nothing, further this report was working for manufacturer, it
was during the addition of adding SalesRep in the where SQL string that this
began.

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

Filter is empty and order value = No

b) Look for controls that refer to the field wrongly (e.g. with the space.)

The controls get the fieldname and value from lookups, the form's cbo
fieldname and lookup list are dynamic similar to the Access Switchboard.

c) Look in the Sorting And Grouping box, to see if the field is wrong there.

None

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

Yes, there is something here that is trying to be too clever. The form when
launched from different swichboard controls refrences a different item in my
reports table, which indicate the target form, report name, query for the
combo and the lable for the combo.

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

That's a good step, I was trying to think of how I could trap that moment
because no matter what I enter for a parameter value the report fails, unless
I choose nothing as my sql where string - see my snipit.

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