Parameter Prompt Annoyingly Appears (sometimes)

  • Thread starter Thread starter JeffP->
  • Start date Start date
J

JeffP->

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....
 
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
 
Thanks for your reply, see my inline... I may post a followup as to my
solution or continued horrors....

Allen Browne said:
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

Reply to group, rather than allenbrowne at mvps dot org.

JeffP-> said:
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....
 
I think you may have misinterpreted AB's advice.

You are getting a parameter prompt upon the opening of a report. There can
only be 2 reasons; the query (that is the source of the report) or the
report

If you open the query standalone and it does not have a parameter prompt....
then it is not the query.

This means that in the report there are controls (fields) in the report -
that can not find any data field in the underlying query when the report
attempts to open... This is not uncommon if someone redesigns to underlying
query but forgets to delete old controls from the report.

Also this same logic is valid for subreports and their queries as well....

That parameter prompt is telling you which field is being sought ...and that
is a helpful hint....
--
NTC


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

Allen Browne said:
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

Reply to group, rather than allenbrowne at mvps dot org.

JeffP-> said:
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....
 
This thread saved my sanity!

I had a union query based on a number of other queries, all ran fine and returned the correct data.
My form and subform showed all the correct data and functioned perfectly.

When I ran the report based on the same query and the data I could see on screen I got the dreaded parameter prompt!!!

Although the above pointed to the report being the problem I even ended up rewriting the queries etc.
After two days and a lot of ~#~~~#**~~~ etc. I found this thread :0) thank god!!!
Two minutes later all working fine no parameter prompt.

SOLUTION:
Very last line on the screen in grouping/sorting was the word "Expression"? I clicked and expanded and there it was the **##***#~~~*!!!!! sort on "ATRecyID" I couldn't even remember adding this line, my data was sorted in the queries it wasn't required - deleated and away we go, perfect.

To be honest it should have been "NRRecyID" but it wasn't needed!

Hope this may help your sanity!

AB to the rescue again :0)




NetworkTrad wrote:

I think you may have misinterpreted AB's advice.
05-Apr-08

I think you may have misinterpreted AB's advice

You are getting a parameter prompt upon the opening of a report. There can
only be 2 reasons; the query (that is the source of the report) or the
repor

If you open the query standalone and it does not have a parameter prompt....
then it is not the query

This means that in the report there are controls (fields) in the report -
that can not find any data field in the underlying query when the report
attempts to open... This is not uncommon if someone redesigns to underlying
query but forgets to delete old controls from the report

Also this same logic is valid for subreports and their queries as well...

That parameter prompt is telling you which field is being sought ...and that
is a helpful hint...
--
NT

:

Previous Posts In This Thread:

Parameter Prompt Annoyingly Appears (sometimes)
I have a form that I set the SQL query to eithe

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

If len(sParam) > 0 the
sSQL = "Year=2007" & " and " & sPara
(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
ORDER BY [Main Job Log].[Job #]
....end quer

...frmReport snipit...
sReportName = sRptNam
sWhereFieldName = Me.lbl_WhereFieldName.Captio
sWhereFieldValue = Me.cbo_RptOptionList.Valu

If Me.cbo_Year.Visible = True The
sYear = "Year=" & Me.cbo_Year.Valu
Else: sYear = "
End I

If Me.cbo_RptOptionList.Value = "_All" The
sWhere = "
Else
sWhere = sWhereFieldName & " = '" & sWhereFieldValue & "'
End I

Select Case Len(Left(sYear, 1)) + Len(Left(sWhere, 2)
Case
sQry = sYear & " and " & sWher
Case
sQry = sWher
Case
sQry = sYea
Case
sQry = sWher
End Selec

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

Try running the report's query on its own.Does it ask for the parameter?
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

Reply to group, rather than allenbrowne at mvps dot org.


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

:

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.

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.

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.

Filter is empty and order value = No

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

None

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.

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.

I think you may have misinterpreted AB's advice.
I think you may have misinterpreted AB's advice.

You are getting a parameter prompt upon the opening of a report. There can
only be 2 reasons; the query (that is the source of the report) or the
report

If you open the query standalone and it does not have a parameter prompt....
then it is not the query.

This means that in the report there are controls (fields) in the report -
that can not find any data field in the underlying query when the report
attempts to open... This is not uncommon if someone redesigns to underlying
query but forgets to delete old controls from the report.

Also this same logic is valid for subreports and their queries as well....

That parameter prompt is telling you which field is being sought ...and that
is a helpful hint....
--
NTC


:


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Customized Find Control for FlowDocuments
http://www.eggheadcafe.com/tutorial...3-721a40cf910c/wpf-customized-find-contr.aspx
 
Back
Top