基于下拉选择的表单中显示的查询的自动更新 [英] Automatic updating of query shown in a form based on dropdown selection

查看:80
本文介绍了基于下拉选择的表单中显示的查询的自动更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这将是有史以来最容易解决的问题,但是花了一个上午寻找答案之后,我仍然无法解决该问题.

I thought this was going to be the easiest question ever to solve, but after spending a morning searching for answers, I still can't get it to work.

我有一个列表框,该列表框在链接到查询的用户表单上显示某些国家/地区的数据.我想允许我的用户根据下拉列表中的选择来列出该列表.

I have a list box showing data for certain countries on a user form that is linked to a query. I want to allow my users to filer that list based on the selection in a dropdown.

这是列表框中行源中的SQL:

This is the SQL in the list box row source:

SELECT tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country
FROM tblFUNDS INNER JOIN tblISIN_Country_Table ON tblFUNDS.ISIN = tblISIN_Country_Table.ISIN
GROUP BY tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country, tblFUNDS.Fund_Selection
HAVING (((tblISIN_Country_Table.Country)=[Forms]![frmMain]![ddnCountry]) AND ((tblFUNDS.Fund_Selection)=0));

列表框和下拉列表中的值均正确显示. 但是,我无法通过下拉菜单来过滤列表.

Both the values in the list box and the dropdown are displaying correctly. However, I have not been able to get the dropdown selection to filter the list.

到目前为止,我已经尝试将以下引用及其不同版本插入到查询列表框中所链接到的行中的查询中:

So far I have tried inserting the following reference and various versions of it into the query that the list box links to in the row source:

[Forms]![frmMain]![ddnCountry]

我还在<下拉列表>中为On Change事件插入了以下代码:

I also inserted the following code for the On Change Event in the Dropdownlist:

Private Sub ddnCountry_Change()
    cmbFIlterSelection.Requery
End Sub

On Change事件会正确触发,因为当我设置断点时,它会停止在一行代码上,但它似乎无能为力.

The On Change event fires correctly because when I set a breakpoint it stops on the one line of code, but it seems to do nothing.

我在做什么错了?

推荐答案

好.经过数小时的寻找答案,现在甚至在这里发布,我发现了问题:

Ok. After hours of looking for answers and now even posting on here, I found the problem:

需要修改SQL查询以包括以下.Text

The SQL Query needed to be modified to include the following .Text

现在它显示为:

[Forms]![frmMain]![ddnCountry].[Text]

这篇关于基于下拉选择的表单中显示的查询的自动更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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