473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Parameters added to Report

I am getting #Name error on a report when I create an unbound text field with the following:
Expand|Select|Wrap|Line Numbers
  1. ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime, Enddate DateTime;
  2. SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
  3. FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
  4. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
What am I doing wrong?
Feb 28 '07 #1
22 1953
MMcCarthy
14,534 Expert Mod 8TB
I am getting #Name error on a report when I create an unbound text field with the following:
Expand|Select|Wrap|Line Numbers
  1. ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime, Enddate DateTime;
  2. SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
  3. FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
  4. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
What am I doing wrong?
Startdate and Enddate are not actually being returned by the query and therefore are not available on the Report.

Mary
Feb 28 '07 #2
Startdate and Enddate are not actually being returned by the query and therefore are not available on the Report.

Mary
I followed the steps as outlined in the following website: http://support.microsoft.com/kb/208630 for database.
Feb 28 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
I followed the steps as outlined in the following website: http://support.microsoft.com/kb/208630 for database.
This will restrict the data being returned to fall between these two dates but won't make them available for use on the report. Standard way to do this would be to have two textboxes on a form to hold the two dates and a command button to open the report.

txtStartDate and txtEndDate are the two textboxes on the form. Command button (cmdOpenReport) has the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenReport()
  2.    DoCmd.OpenReport "ReportName", , , "[tblMaster.Date] Between " & txtStartdate & " And " & txtEnddate
  3. End Sub
  4.  
The record source of the report is as follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
  2. FROM tblMaster INNER JOIN tblSupplier 
  3. ON tblMaster.suppName = tblSupplier.Supplier
  4. WHERE (((tblMaster.Audit)=False) AND ((tblMaster.PA)=False)));
  5.  
Now as long as the form remains open the dates are available to you.
Expand|Select|Wrap|Line Numbers
  1. ="Report Period From " & [Forms]![FormName]![txtStartdate] & " Through " & [Forms]![FormName]![txtEnddate]
  2.  
Mary
Feb 28 '07 #4
Unfortunately, I use a report call form for all reports. Using the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenReport_Click()
  2.  ' Purpose:  Opens the report selected in the list box.
  3.     On Error GoTo cmdOpenReport_ClickErr
  4.     If Not IsNull(Me.lstreports) Then
  5.         DoCmd.OpenReport Me.lstreports, IIf(Me.ChkPreview.Value, acViewPreview, acViewNormal)
  6.     End If
  7.     Exit Sub
  8.  
  9. cmdOpenReport_ClickErr:
  10.     Select Case Err.Number
  11.     Case 2501   ' Cancelled by user, or by NoData event.
  12.         MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
  13.     Case Else
  14.         MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdOpenReport_Click()"
  15.     End Select
  16.     Resume Next
  17. End Sub
Anyway to make this work also or will this one report have to have a seperate page?
Feb 28 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Unfortunately, I use a report call form for all reports. Using the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenReport_Click()
  2.  ' Purpose:  Opens the report selected in the list box.
  3.     On Error GoTo cmdOpenReport_ClickErr
  4.     If Not IsNull(Me.lstreports) Then
  5.         DoCmd.OpenReport Me.lstreports, IIf(Me.ChkPreview.Value, acViewPreview, acViewNormal)
  6.     End If
  7.     Exit Sub
  8.  
  9. cmdOpenReport_ClickErr:
  10.     Select Case Err.Number
  11.     Case 2501   ' Cancelled by user, or by NoData event.
  12.         MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
  13.     Case Else
  14.         MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdOpenReport_Click()"
  15.     End Select
  16.     Resume Next
  17. End Sub
Anyway to make this work also or will this one report have to have a seperate page?
No just add the text boxes to this form and change the open report code to add the criteria of the dates.

Mary
Feb 28 '07 #6
But what if the report that is being pulled up has different parameters other than dates?
Feb 28 '07 #7
To be a bit more specific this Open Command is for all reports that are populated in a list box. Will adding the txtstartdate and txtenddate to the open command effect all reports in the list box?
Feb 28 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
To be a bit more specific this Open Command is for all reports that are populated in a list box. Will adding the txtstartdate and txtenddate to the open command effect all reports in the list box?
Yes it will. Unfortunately you can't have it both ways.

Mary
Mar 1 '07 #9
Ugh....thanks for the help. I suppose I don't need it that bad. How come all the help sites say I should be able to add a text box
Expand|Select|Wrap|Line Numbers
  1. =Reports![reportname]![parametername]
? www.databasedev.co.uk/printing_parameters.html

They even show it in use. Is it because my date field is named "Date"?
Mar 1 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
Ugh....thanks for the help. I suppose I don't need it that bad. How come all the help sites say I should be able to add a text box
Expand|Select|Wrap|Line Numbers
  1. =Reports![reportname]![parametername]
? www.databasedev.co.uk/printing_parameters.html

They even show it in use. Is it because my date field is named "Date"?
To be honest I've never tried to use a parameter that way. What happens if you set up a control like this on your report?

BTW, ideally you should never name a field Date as it can be confused with the Date function.

Mary
Mar 1 '07 #11
I have tried it and I get the #Name? error. I don't understand why all the websites say it works this way and it doesn't.
Mar 1 '07 #12
MMcCarthy
14,534 Expert Mod 8TB
I have tried it and I get the #Name? error. I don't understand why all the websites say it works this way and it doesn't.
Let me bring this to the attention of some of the other site experts who may have heard of this.

Mary
Mar 1 '07 #13
nico5038
3,080 Expert 2GB
Hmm, logically it should work, but I would never use this as I dislike the two popup inputboxes.
Better to place two (hidden) fields for the startdate and enddate on your form with the listbox. (Personally I prefer to use a combo based on a "select distinct DateField from tblYours order by desc" as that will allow only to chose existing dates and thus the report will have atleast one row of data -)

Now in the listbox's onClick event I would test for the specific report like:

IF Me.lstReports = "rptDateReport" then
Me.txtStartDate.visible = true
Me.txtEndDate.visible = true
else
Me.txtStartDate.visible = false
Me.txtEndDate.visible = false
endif

Thus the fields will be visible inly for that report and you could even disable the print button to force the user to enter them. (requires additional testing in the field/combo's AfterUdate event...)
Finally use in your report for the headertext:
="Report Period From " & [Forms]![FormName]![txtStartdate] & " Through " & [Forms]![FormName]![txtEnddate]

Getting the idea ?

Nic;o)
Mar 1 '07 #14
Rabbit
12,516 Expert Mod 8TB
I was able to replicate the process you provided from the microsoft sample database. Have you tried renaming your date field? Does the query run okay?
Mar 1 '07 #15
NeoPa
32,556 Expert Mod 16PB
I may be missing something here, but is what you're after simply :
Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime,
  2.            Enddate DateTime;
  3. SELECT tblMaster.rptNumber,
  4.        tblMaster.suppName,
  5.        tblMaster.Date,
  6.        tblMaster.Nonconformance,
  7.        tblMaster.Audit,
  8.        tblMaster.PA
  9.        [Startdate],
  10.        [Enddate]
  11. FROM tblMaster INNER JOIN tblSupplier
  12.   ON tblMaster.suppName = tblSupplier.Supplier
  13. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate])
  14.   AND ((tblMaster.Audit)=False)
  15.   AND ((tblMaster.PA)=False));
We're discussing some of the other issues in another thread I know so I won't comment on that here (Comparing booleans with True/False values etc).
Mar 1 '07 #16
MMcCarthy
14,534 Expert Mod 8TB
I may be missing something here, but is what you're after simply :
Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime,
  2.            Enddate DateTime;
  3. SELECT tblMaster.rptNumber,
  4.        tblMaster.suppName,
  5.        tblMaster.Date,
  6.        tblMaster.Nonconformance,
  7.        tblMaster.Audit,
  8.        tblMaster.PA
  9.        [Startdate],
  10.        [Enddate]
  11. FROM tblMaster INNER JOIN tblSupplier
  12.   ON tblMaster.suppName = tblSupplier.Supplier
  13. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate])
  14.   AND ((tblMaster.Audit)=False)
  15.   AND ((tblMaster.PA)=False));
We're discussing some of the other issues in another thread I know so I won't comment on that here (Comparing booleans with True/False values etc).
The problem is he then wants to use the parameter values in an unbound textbox on the report.
Mar 1 '07 #17
NeoPa
32,556 Expert Mod 16PB
In what sense is a used TextBox unbound (ever)?
Clearly he can use the =[Startdate] form of setting the value to display. Or even =[Startdate]+7 etc. Why must it be unbound?
Mar 1 '07 #18
MMcCarthy
14,534 Expert Mod 8TB
In what sense is a used TextBox unbound (ever)?
Clearly he can use the =[Startdate] form of setting the value to display. Or even =[Startdate]+7 etc. Why must it be unbound?
Look at the first code in Post#1
Mar 1 '07 #19
NeoPa
32,556 Expert Mod 16PB
And why would that not work fine now - with my recently posted SQL (post #16)?
Mar 1 '07 #20
NeoPa
32,556 Expert Mod 16PB
Check out post #16 for a workable solution :)
Mar 2 '07 #21
ADezii
8,834 Expert 8TB
I am getting #Name error on a report when I create an unbound text field with the following:
Expand|Select|Wrap|Line Numbers
  1. ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime, Enddate DateTime;
  2. SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date,
  3. tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
  4. FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
  5. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
What am I doing wrong?
Sorry I jumped in so late on the conversation. Try adding the Parameters themselves as add ons to the SELECT Statement at the end. Do not use a Table Qualifier as in:
Expand|Select|Wrap|Line Numbers
  1. PARAMETERS Startdate DateTime, Enddate DateTime;
  2. SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date,
  3. tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA, 
  4. [Startdate], [Enddate]
  5. FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
  6. WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
Mar 2 '07 #22
NeoPa
32,556 Expert Mod 16PB
That's a brilliant idea ADezii :D Check out post #16.
(Having said that of course, your post explains it better :))
Mar 2 '07 #23

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Aaron | last post by:
The following code works fine when previewing a Crystal report using ASP, EXCEPT when it gets to a report using a SubReport and its associated parameters. The whole report just comes up blank with...
0
by: Omavlana | last post by:
Hi, pls clarify these 2 questions. 1. How can I send some values of globla variables from VB.NET to crystal report. I want to show these values on report. 2. I have added an SQL query in my...
1
by: Scott Sabo | last post by:
Hello- I recently modified a database at work to be able to track employee stats in two locations. Formerly, the employees were all in Reno, Nv that were listed in the database, now I have added...
8
by: Mark Flippin | last post by:
This is for a reporting problem using: Access 2000 SQL Server 2000 Both at SP3 I've a stored procedure in SQL Server 2000 which builds a result set from a disparate set of tables, utilizing...
0
by: Craig Faulkner | last post by:
I have been fighting through my first crystal report in VS2003.NET and have made some headway. Here is what I've done: 1. Created a crystal report in VS2003 from a SQL stored procedure with...
0
by: stephan | last post by:
I know that this has been beaten to death but I can't seem to resolve my issues (I have 2 of them). I have created a class that exposes a public method which returns a datatable as a datasource...
10
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual...
0
by: Mariana | last post by:
Hello, I am exporting reports in pdf format from .net 2005 . The export is working fine; however the user values of stored procedure parameters does not show in the report. What do I need to do in...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.