I am getting #Name error on a report when I create an unbound text field with the following: - ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this: - PARAMETERS Startdate DateTime, Enddate DateTime;
-
SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
-
FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
-
WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
What am I doing wrong?
22 1953
I am getting #Name error on a report when I create an unbound text field with the following: - ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this: - PARAMETERS Startdate DateTime, Enddate DateTime;
-
SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
-
FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
-
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
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.
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. -
Private Sub cmdOpenReport()
-
DoCmd.OpenReport "ReportName", , , "[tblMaster.Date] Between " & txtStartdate & " And " & txtEnddate
-
End Sub
-
The record source of the report is as follows: -
SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date, tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
-
FROM tblMaster INNER JOIN tblSupplier
-
ON tblMaster.suppName = tblSupplier.Supplier
-
WHERE (((tblMaster.Audit)=False) AND ((tblMaster.PA)=False)));
-
Now as long as the form remains open the dates are available to you. -
="Report Period From " & [Forms]![FormName]![txtStartdate] & " Through " & [Forms]![FormName]![txtEnddate]
-
Mary
Unfortunately, I use a report call form for all reports. Using the following code: - Private Sub cmdOpenReport_Click()
-
' Purpose: Opens the report selected in the list box.
-
On Error GoTo cmdOpenReport_ClickErr
-
If Not IsNull(Me.lstreports) Then
-
DoCmd.OpenReport Me.lstreports, IIf(Me.ChkPreview.Value, acViewPreview, acViewNormal)
-
End If
-
Exit Sub
-
-
cmdOpenReport_ClickErr:
-
Select Case Err.Number
-
Case 2501 ' Cancelled by user, or by NoData event.
-
MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
-
Case Else
-
MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdOpenReport_Click()"
-
End Select
-
Resume Next
-
End Sub
Anyway to make this work also or will this one report have to have a seperate page?
Unfortunately, I use a report call form for all reports. Using the following code: - Private Sub cmdOpenReport_Click()
-
' Purpose: Opens the report selected in the list box.
-
On Error GoTo cmdOpenReport_ClickErr
-
If Not IsNull(Me.lstreports) Then
-
DoCmd.OpenReport Me.lstreports, IIf(Me.ChkPreview.Value, acViewPreview, acViewNormal)
-
End If
-
Exit Sub
-
-
cmdOpenReport_ClickErr:
-
Select Case Err.Number
-
Case 2501 ' Cancelled by user, or by NoData event.
-
MsgBox "Report cancelled, or no matching data.", vbInformation, "Information"
-
Case Else
-
MsgBox "Error " & Err & ": " & Error$, vbInformation, "cmdOpenReport_Click()"
-
End Select
-
Resume Next
-
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
But what if the report that is being pulled up has different parameters other than dates?
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?
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
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 - =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"?
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 - =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
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.
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
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)
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?
NeoPa 32,556
Expert Mod 16PB
I may be missing something here, but is what you're after simply : - PARAMETERS Startdate DateTime,
-
Enddate DateTime;
-
SELECT tblMaster.rptNumber,
-
tblMaster.suppName,
-
tblMaster.Date,
-
tblMaster.Nonconformance,
-
tblMaster.Audit,
-
tblMaster.PA
-
[Startdate],
-
[Enddate]
-
FROM tblMaster INNER JOIN tblSupplier
-
ON tblMaster.suppName = tblSupplier.Supplier
-
WHERE (((tblMaster.Date) Between [Startdate] And [Enddate])
-
AND ((tblMaster.Audit)=False)
-
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).
I may be missing something here, but is what you're after simply : - PARAMETERS Startdate DateTime,
-
Enddate DateTime;
-
SELECT tblMaster.rptNumber,
-
tblMaster.suppName,
-
tblMaster.Date,
-
tblMaster.Nonconformance,
-
tblMaster.Audit,
-
tblMaster.PA
-
[Startdate],
-
[Enddate]
-
FROM tblMaster INNER JOIN tblSupplier
-
ON tblMaster.suppName = tblSupplier.Supplier
-
WHERE (((tblMaster.Date) Between [Startdate] And [Enddate])
-
AND ((tblMaster.Audit)=False)
-
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.
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?
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
NeoPa 32,556
Expert Mod 16PB
And why would that not work fine now - with my recently posted SQL (post #16)?
NeoPa 32,556
Expert Mod 16PB
Check out post #16 for a workable solution :)
I am getting #Name error on a report when I create an unbound text field with the following: - ="Report Period From" & " " & [Startdate] & " " & "Through" & " " & [Enddate]
The query this is based on is this: - PARAMETERS Startdate DateTime, Enddate DateTime;
-
SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date,
-
tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA
-
FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
-
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: - PARAMETERS Startdate DateTime, Enddate DateTime;
-
SELECT tblMaster.rptNumber, tblMaster.suppName, tblMaster.Date,
-
tblMaster.Nonconformance, tblMaster.Audit, tblMaster.PA,
- [Startdate], [Enddate]
-
FROM tblMaster INNER JOIN tblSupplier ON tblMaster.suppName = tblSupplier.Supplier
-
WHERE (((tblMaster.Date) Between [Startdate] And [Enddate]) AND ((tblMaster.Audit)=False) AND ((tblMaster.PA)=False));
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 :))
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
| |