简体   繁体   English

MS Access 2003报告串联

[英]MS Access 2003 report concatenation

I am currently working on a report for MS Access 2003 with three fields consisting of a [Lease Start] Date, [Lease End] Date, and [Financial Notes] String. 我当前正在处理MS Access 2003的报告,其中包含三个字段,这些字段包括[租约开始日期],[租约结束日期]和[财务注释]字符串。 The Management wants all three combined under Financial Notes on the Report. 管理层希望将这三份报告合并在财务报表中。 I have set up the Concatenation as: 我将串联设置为:

=CVar([Lease Start]) & " - " & CVar([Lease Ends]) & " " & [Financial Notes]

Yet I am getting a # Error when I run the report. 但是,运行报表时出现#错误。

See what that expression returns in a query of your report's record source. 在查询报告记录源时查看该表达式返回的内容。

SELECT
    CVar([Lease Start]) & " - "
        & CVar([Lease Ends])
        & " " & [Financial Notes]
        AS report_expression
FROM YourTableOrQuery;

I don't know whether this is significant, but I'm puzzled why you're using CVar() there. 我不知道这是否很重要,但是我很困惑为什么您在那里使用CVar() When you give it a Date/Time value, it returns a Date/Time value. 当您给它一个日期/时间值时,它将返回一个日期/时间值。 Access should oblige by casting that to a string when you concatenate, but it would do the same for the original Date/Time value without CVar . 连接时, 应该通过将其强制转换为字符串来进行访问,但是对于不带CVar的原始Date / Time值, CVar将相同。 I don't understand why CVar is useful there. 我不明白为什么CVar在这里有用。

Since you're building a string, my inclination would be to use Format() . 由于您正在构建字符串,因此我倾向于使用Format()

SELECT
    Format([Lease Start], "m/d/yyyy") & " - "
        & Format([Lease Ends], "m/d/yyyy")
        & " " & [Financial Notes]
        AS report_expression
FROM YourTableOrQuery;

However as I admitted, I have no clue whether this is a significant issue. 但是,正如我承认的那样,我不知道这是否是一个重大问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM