English 中文(简体)
生活津贴
原标题:MS Access - Division by zero + Nz()

我有两个交叉问题(结构见下文)。 很简单。 第一是每座城市中我公司拥有的每个建筑类型,第二座是整个城市按类型分列的所有(而不仅仅是公司拥有的)建筑。

我想要做的是计算一个百分比,但我有很多麻烦。 我认为我很接近尾声,但出于某种原因,我的<条码>Nz(功能是正常运转的。 我不断看到“零差错分配” 这里的公式是:

DCount(
  "[ID]","[Company_owned]") / DCount(
    "[ID]","[City_Totals]", "[Year_built]=2000" & Nz(Year_built, "null")
  )
)

这里是我的交叉问题。

1 P-4, 1 P-3, 1 FS, 1 NS

╔═══════════════════════════════════════════════════════════════════════════════╗
║               Building type:          1     2     3     4      5      6     7 ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║     City      Atlanta                 0     7     0     2      3      4     9 ║
║               New York                0     0     2     5      7      8     2 ║
║               San Francisco           1     1     2     3      4      5     6 ║
╚═══════════════════════════════════════════════════════════════════════════════╝

2)

╔═══════════════════════════════════════════════════════════════════════════════╗
║               Building type:          1     2     3     4      5      6     7 ║
╠═══════════════════════════════════════════════════════════════════════════════╣
║     City      Atlanta                 8     9     3     2      3      7     9 ║
║               New York                0     0     2     7      7      9     2 ║
║               San Francisco           3     1     9     3      5      5     8 ║
╚═══════════════════════════════════════════════════════════════════════════════╝

请允许我告诉我,我为什么看到“零分配”错误,这是否是计算两个交叉提问中数据百分比的正确战略(我也考虑在报告内进行所有百分比计算,但这似乎更令人怀疑)

问题回答

我在这里猜想一点,但我认为,你所期待的是:

DCount("[ID]","[Company_owned]") / _
DCount("[ID]","[City_Totals]", "[Year_built]" & _
  IIf(IsNull(Year_built), " Is Null", "=" & Year_built))

<>说明: 如果你在问询中这样做的话,请离开线上连续的果园(_),然后共同操作每一行。

我认为,你之所以遇到麻烦,是因为你所写的第二项标准是对以下一些内容的评价:[Year_built]=2000<0/code>或本[Year_built]=2000null

即使将<代码>2000<>>/代码>留在贵国的问题中只是一个字体,但<代码>[年份_built]=null<代码>仍不做你似乎期望的。 在此情况下,需要<代码>Is Null





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签