在ADP中打开报告 [英] Opening reports in ADP

查看:58
本文介绍了在ADP中打开报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁可以告诉我以下有什么问题?无论我做什么

报告都会带回表中的所有记录,而不仅仅是指定日期之间的




Dim strDocName As String

Dim strIncidentDate1 As Date

Dim strIncidentDate2 As Date


strIncidentDate1 = Me!txtReportStartDate

strIncidentDate2 = Me!txtReportEndDate

strDocName =" rptRedYellow"


DoCmd.OpenReport stDocName,acViewPreview ,," [IncidentDate]> = " &

strIncidentDate1& "而" &安培; " [IncidentDate] LT; =" &安培; strIncidentDate2


这对我的整个数据库项目至关重要,我正在弄清楚我的头发还剩下什么。

帮助!!!

解决方案

你写了

谁能告诉我以下是什么问题?无论我做什么
报告都会带回表中的所有记录,而不仅仅是指定日期之间的记录。

Dim strDocName As String
Dim strIncidentDate1 As Date
Dim strIncidentDate2作为日期

strIncidentDate1 = Me!txtReportStartDate
strIncidentDate2 = Me!txtReportEndDate
strDocName =" rptRedYellow"

DoCmd。 OpenReport stDocName,acViewPreview," [IncidentDate]> =" &
strIncidentDate1& "而" &安培; " [IncidentDate] LT; =" &安培; strIncidentDate2

这对我的整个数据库项目至关重要,我正在弄清楚我的头发还剩下什么。

帮助!!!



如果您在ADP中,我认为数据保存在SQL Server中。

我从未使用过ADP,但我相信通常在ADP中SQL的语法必须与T-SQL匹配。在这种情况下,我希望

连接运算符为+而不是& ;.可能是你的过滤器

字符串被完全忽略了。


在参与报告和管理它的代码之前做了

确保你可以编写一个返回所需数据的查询。

你应该尝试使用MsgBox显示你正在生成的过滤字符串




此外,需要在

过滤字符串中识别IncidentDate字符串。如果您是硬编码,它将如下所示:

" [IncidentDate]> =''1-MAR-2005''"


尝试用单引号括起字符串变量。


DoCmd.OpenReport stDocName,acViewPreview ,," [IncidentDate]> =''" &

strIncidentDate1& "''和' &安培; [IncidentDate]< =''" &安培; strIncidentDate2

& "''"


最后,在SQL Server中使日期查询工作取决于获得标准的

格式。你还没有告诉我们

strIncidentDate1和strIncidentDate2的格式 - 它们是由

用户手工输入还是从表中派生出来的?

-

Albert Marshall

Marshall Le Botmel Ltd

01242 222017



感谢Albert


我试过了,但它只是''无效使用Null''。


strIncidentDates(1& 2)最终来自一个表,该表存储了由前一个用户最初输入的学习期限日期。


再次感谢

Colin

***通过开发人员指南 http发送://www.developersdex.com ***

不要只参加USENET ......获得奖励!

" Colin Mardell" <共*********** @ btopenworld.com>写了

我试过了,但它只是给''无效使用Null''。

strIncidentDates(1& 2)最终来自一个存储
学校学期日期最初由前一个用户输入。




如果这些日期来自文本框,但它不是绑定文本框,您将

需要将它们包含在CVDate()函数中。

-

Darryl Kerkeslager


电力腐败。<绝对权力绝对腐败。

知识就是力量。

www.adcritic.com/interactive/view.php?id=5927


Can anyone tell me what is wrong with the following? Whatever I do
the report brings back all records in the table, rather than just
those between the dates specified.

Dim strDocName As String
Dim strIncidentDate1 As Date
Dim strIncidentDate2 As Date

strIncidentDate1 = Me!txtReportStartDate
strIncidentDate2 = Me!txtReportEndDate
strDocName = "rptRedYellow"

DoCmd.OpenReport stDocName, acViewPreview, , "[IncidentDate]>=" &
strIncidentDate1 & "And" & "[IncidentDate]<=" & strIncidentDate2

This is crucial to my whole database project and I am tearing out what
little I have left of my hair.

Help!!!

解决方案

You wrote

Can anyone tell me what is wrong with the following? Whatever I do
the report brings back all records in the table, rather than just
those between the dates specified.

Dim strDocName As String
Dim strIncidentDate1 As Date
Dim strIncidentDate2 As Date

strIncidentDate1 = Me!txtReportStartDate
strIncidentDate2 = Me!txtReportEndDate
strDocName = "rptRedYellow"

DoCmd.OpenReport stDocName, acViewPreview, , "[IncidentDate]>=" &
strIncidentDate1 & "And" & "[IncidentDate]<=" & strIncidentDate2

This is crucial to my whole database project and I am tearing out what
little I have left of my hair.

Help!!!



If you are in an ADP I assume that the data is held in SQL Server.
I''ve never worked with ADPs but I believe that the syntax of SQL
generally in ADPs has to match T-SQL. In that case I would expect the
concatenation operator to be + rather than &. It may be that your filter
string is being completely ignored.

Before getting involved in the report and the code to manage it make
sure that you can write a query that returns the data you require.
What you should try is using a MsgBox to display the filter string that
you are generating.

Also, the IncidentDate strings need to be identified as such in the
filter string. If you were hard coding it would look like this:
"[IncidentDate]>= ''1-MAR-2005''"

Try putting single quotes in to surround the string variables.

DoCmd.OpenReport stDocName, acViewPreview, , "[IncidentDate]>= ''" &
strIncidentDate1 & "'' And " & "[IncidentDate]<= ''" & strIncidentDate2
& "''"

Finally, making date queries work in SQL Server depends on getting the
format of the criteria right. You haven''t told us the format of
strIncidentDate1 and strIncidentDate2 -- are they hand entered by the
user or derived from tables?

--
Albert Marshall
Marshall Le Botmel Ltd
01242 222017



Thanks Albert

I tried that but it just gives ''Invalid use of Null''.

The strIncidentDates(1&2) ultimately derive from a table which stores
School Term dates originally entered by a previous user.

Thanks again
Colin
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


"Colin Mardell" <co***********@btopenworld.com> wrote

I tried that but it just gives ''Invalid use of Null''.

The strIncidentDates(1&2) ultimately derive from a table which stores
School Term dates originally entered by a previous user.



If these dates come from a textbox, but it is not a bound textbox, you will
need to enclose them in the CVDate() function.
--
Darryl Kerkeslager

Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927


这篇关于在ADP中打开报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆