SQL查询将忽略其引用的控件 [英] SQL Query ignores controls that it refrences

查看:64
本文介绍了SQL查询将忽略其引用的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问表单,其中包含一个列表框,该列表框可从以下查询中获取数据:

I have an Access Form that contains a ListBox that gets data from the following query:

SELECT tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR AS [Retro Frei], 
tblMorningstar_Data.[DEU Tax Transparence], tblMorningstar_Data.[Distribution Status], 
tblISIN_Country_Table.Country

FROM 
(tblFUNDS INNER JOIN tblISIN_Country_Table ON tblFUNDS.ISIN = tblISIN_Country_Table.ISIN) 
INNER JOIN tblMorningstar_Data ON 
(tblFUNDS.Fund_Selection = tblMorningstar_Data.Fund_Selection) 
AND (tblFUNDS.ISIN = tblMorningstar_Data.ISIN)

GROUP BY tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, 
tblMorningstar_Data.[DEU Tax Transparence], tblMorningstar_Data.[Distribution Status], 
tblISIN_Country_Table.Country, tblFUNDS.Fund_Selection

HAVING (((tblFUNDS.RDR) Like Nz([Forms]![frmMain]![ddnRDR],'*')) AND
((tblMorningstar_Data.[DEU Tax Transparence]) Like Nz([Forms]![frmMain]![ddnTax],'*')) AND
((tblMorningstar_Data.[Distribution Status]) Like Nz([Forms]![frmMain]![ddnDistribution],'*')) 
AND ((tblISIN_Country_Table.Country) Like Nz([Forms]![frmMain]![ddnCountry].[Text],'*')) 
AND ((tblFUNDS.Fund_Selection)=0));

我已经设置了查询所引用的各种控件,以在单击各个下拉字段的_AfterUpdate事件上运行上述相同的SQL语句.它们全部执行,我可以通过a)列表框更新和b)设置断点来判断.

I have set up the various controls referenced by the query to run the same SQL statement above on the _AfterUpdate event of clicking the various dropdown fields. They all execute, which I can tell by a) the list box updating and b) by setting break points.

问题是这样的: 例如,当我更改国家/地区的下拉字段的值时,它会按国家/地区进行过滤.然后,如果我为Tax设置了下拉字段,它将向Tax提交,但会忽略在国家/地区下拉控件中设置的值(以及其他下拉列表中的所有值).

The issues is this: When I change the value of the dropdown field for country for example, it filters by country. If I then set the dropdown field for Tax, it fileters for Tax, but ignores the value set in the country dropdown control (and all values in the other dropdowns as well).

我的问题: 为什么会发生这种情况,如何立即基于所有下拉字段的值对其进行过滤?

My question: Why does this happen and how can I get it to filter based on the values of ALL the dropdown fields at once?

推荐答案

就像在评论中一样,尝试:

Like in comment, try:

SELECT tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR AS [Retro Frei], tblMorningstar_Data.[DEU Tax Transparence], tblMorningstar_Data.[Distribution Status], tblISIN_Country_Table.Country

FROM (tblFUNDS INNER JOIN tblISIN_Country_Table ON tblFUNDS.ISIN = tblISIN_Country_Table.ISIN) INNER JOIN tblMorningstar_Data ON (tblFUNDS.Fund_Selection = tblMorningstar_Data.Fund_Selection) AND (tblFUNDS.ISIN = tblMorningstar_Data.ISIN)

WHERE (((tblFUNDS.RDR) Like Nz([Forms]![frmMain]![ddnRDR],'*')) AND ((tblMorningstar_Data.[DEU Tax Transparence]) Like Nz([Forms]![frmMain]![ddnTax],'*')) AND ((tblMorningstar_Data.[Distribution Status]) Like Nz([Forms]![frmMain]![ddnDistribution],'*')) AND ((tblISIN_Country_Table.Country) Like Nz([Forms]![frmMain]![ddnCountry].[Text],'*')) AND ((tblFUNDS.Fund_Selection)=0))

GROUP BY tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblMorningstar_Data.[DEU Tax Transparence], tblMorningstar_Data.[Distribution Status], tblISIN_Country_Table.Country, tblFUNDS.Fund_Selection;

这篇关于SQL查询将忽略其引用的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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