简体   繁体   English

为什么不能更改MS Access报告中数字字段的格式?

[英]Why can't I change format for numeric field in MS Access report?

I have performance data (95%, 100%, 120%, etc.) that needs formatted as a percent so I can sort and conditionally format. 我有需要格式化为百分比的性能数据(95%,100%,120%等),因此我可以进行排序和有条件地格式化。 Upon opening the properties window of my MS Access report, it will let me change the format (General Number, Currency, Percent, etc.) for values extracted directly from a table, such as employee_id or shift . 打开MS Access报表的属性窗口后,它将使我更改直接从表中提取的值的格式(常规数字,货币,百分比等),例如employee_idshift But others, such as [6 wks ago] , [5 wks ago] , and on down do not allow me to do this. 但是其他人,例如[6 wks ago][5 wks ago]和倒下,则不允许我执行此操作。 Is this because the field is the result of an IIF() statement? 这是因为该字段是IIF()语句的结果吗? The following query is my original query: 以下查询是我的原始查询:

SELECT 
D2s_roster_tbl.employee_id AS ID,
D2s_roster_tbl.employee_name AS Name, 
D2s_roster_tbl.position_desc AS [Position],
D2s_roster_tbl.adj_hire_dt AS [Hire DT], 
D2s_roster_tbl.shift_nbr AS Shift, 
D2s_roster_tbl.supervisor,
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/09],[trndPerformanceQry_crosstab].[11/09]) AS [6 wks ago], 
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/16],[trndPerformanceQry_crosstab].[11/16]) AS [5 wks ago], 
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/23],[trndPerformanceQry_crosstab].[11/23]) AS [4 wks ago], 
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/30],[trndPerformanceQry_crosstab].[11/30]) AS [3 wks ago], 
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[12/07],[trndPerformanceQry_crosstab].[12/07]) AS [2 wks ago], 
IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[12/14],[trndPerformanceQry_crosstab].[12/14]) AS [Last wk], 

FROM 
((D2s_roster_tbl 
LEFT JOIN trndLoaderPerformanceTbl_Crosstab ON D2s_roster_tbl.employee_id = trndLoaderPerformanceTbl_Crosstab.employee_id) 
LEFT JOIN trndPerformanceQry_Crosstab ON D2s_roster_tbl.employee_id = trndPerformanceQry_Crosstab.employee_id)
LEFT JOIN trndPerfFormatPercent_Crosstab ON D2s_roster_tbl.employee_id = trndPerfFormatPercent_Crosstab.employee_id;

So I thought OK, it doesn't want to format the result of such a conditional statement. 因此,我认为可以,它不想格式化这种条件语句的结果。 So I put the series of IIF()s in the FROM statement and selected those values directly, as shown below: 因此,我将一系列IIF()s放入FROM语句中,然后直接选择这些值,如下所示:

SELECT
D2s_roster_tbl.employee_id AS ID,
D2s_roster_tbl.employee_name AS Name,
D2s_roster_tbl.position_desc AS [Position],
D2s_roster_tbl.adj_hire_dt AS [Hire DT],
D2s_roster_tbl.shift_nbr AS Shift,
D2s_roster_tbl.supervisor,
j.[6 wks ago],
j.[5 wks ago],
j.[4 wks ago],
j.[3 wks ago],
j.[2 wks ago],
j.[Last wk]

FROM
((D2s_roster_tbl
LEFT JOIN trndLoaderPerformanceTbl_Crosstab ON D2s_roster_tbl.employee_id = trndLoaderPerformanceTbl_Crosstab.employee_id)
LEFT JOIN trndPerformanceQry_Crosstab ON D2s_roster_tbl.employee_id = trndPerformanceQry_Crosstab.employee_id)
LEFT JOIN (SELECT
    d2s_roster_tbl.employee_id,
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/09],[trndPerformanceQry_crosstab].[11/09]) AS [6 wks ago], 
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/16],[trndPerformanceQry_crosstab].[11/16]) AS [5 wks ago],
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/23],[trndPerformanceQry_crosstab].[11/23]) AS [4 wks ago], 
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[11/30],[trndPerformanceQry_crosstab].[11/30]) AS [3 wks ago], 
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[12/07],[trndPerformanceQry_crosstab].[12/07]) AS [2 wks ago], 
    IIf([D2s_roster_tbl].[Position_desc] Like "*loader*",[trndLoaderPerformanceTbl_Crosstab].[12/14],[trndPerformanceQry_crosstab].[12/14]) AS [Last wk]

   FROM 
   ((D2s_roster_tbl 
   LEFT JOIN trndLoaderPerformanceTbl_Crosstab ON D2s_roster_tbl.employee_id = trndLoaderPerformanceTbl_Crosstab.employee_id) 
   LEFT JOIN trndPerformanceQry_Crosstab ON D2s_roster_tbl.employee_id = trndPerformanceQry_Crosstab.employee_id))  AS J ON d2s_roster_tbl.employee_id = j.employee_id;

It doesn't allow me to format the [n wks ago] columns from this query either. 它也不允许我格式化此查询的[n wks ago]列。 My original performance tables have 4 columns: employee_id , week_ending_dt , goal_hrs , and hrs_worked . 我的原始绩效表有4列: employee_idweek_ending_dtgoal_hrshrs_worked This data goes for the past 6 weeks, so I created crosstab queries to give a different column for each week (we're using this to see how performance is trending week over week). 该数据用于过去6周,因此我创建了交叉表查询以为每周提供不同的列(我们使用它来查看性能如何逐周趋势)。 Loader performance is stored separately from others' performance, so that's why I need the IIF() in the query. 加载程序的性能与其他性能的存储是分开存储的,因此这就是为什么我在查询中需要IIF()的原因。 Is there some way to get this information that keeps the end performance values as numeric values whose format can be changed? 有什么方法可以获取此信息,以使最终性能值保持为可以更改格式的数字值?

This here was my original question, but my lack of specificity means this answer is not feasible. 是我最初的问题,但是我缺乏专​​一性,意味着这个答案不可行。 Thank you! 谢谢!

It turns out that the query that feeds the crosstab had the following performance expression: 事实证明,提供给交叉表的查询具有以下性能表达式:

IIf([d2s_performance_tbl].[hrs_worked]=0,"", Round(([d2s_performance_tbl].[goal_hrs]/[d2s_performance_tbl].[hrs_worked]),2)) . IIf([d2s_performance_tbl].[hrs_worked]=0,"", Round(([d2s_performance_tbl].[goal_hrs]/[d2s_performance_tbl].[hrs_worked]),2))

Removing the IIF() to leave just 删除IIF()离开

Round(([d2s_performance_tbl].[goal_hrs]/[d2s_performance_tbl].[hrs_worked]),2)

leaves the values as numbers, which does follow through to the report, allowing me to change to percent and sort and all the other fun things that come with numeric values. 将值保留为数字,这会一直报告到报表中,使我可以更改为百分比和排序以及数字值附带的所有其他有趣的功能。

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

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