过滤表格 [英] Filter on Form

查看:72
本文介绍了过滤表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,


我已经在互联网上搜索了一个解决方案,但找不到任何让我轻松的东西。


我是创建访问数据库的新手(我看到很多新手来到这里)我正在尝试自学VB,但我还没有。


我在访问2003中有一个数据库,在我的主窗体[患者]上它的来源是来自一个

qry [Qry_All_Patiens],它是从表创建的[Tbl_All_Patients]。表单上可用的字段之一是PTstatus。患者可以有几种状态


EX:


PT状态:A,B,C,D,E,F,4,8 ,1

我创建了一个包含所有患者状态[Tbl_Status]的表格。我想用表格(Tbl_Status)在表单上创建一个组合框,允许我按状态过滤。因此,如果我只想查看身份4中的患者,我可以过滤它然后移除过滤器,以便我可以回到所有记录。


有没有办法我可以编写组合框来执行此操作。如果我不需要使用VB,我还能做些什么来完成这项工作。如果无法完成,请告诉我。我不知道在VB中可以做什么或不能做什么。感谢您的任何反馈。

解决方案


嗨专家,


我我已经在互联网上搜索了一个解决方案,但找不到任何能让我轻松的东西。


我是创建访问数据库的新手(我看到很多新手来到这里)我正在尝试自学VB,但我还没有。


我在访问2003中有一个数据库,在我的主窗体[患者]上它的来源是来自一个

qry [Qry_All_Patiens],它是从表创建的[Tbl_All_Patients]。表单上可用的字段之一是PTstatus。患者可以有几种状态


EX:


PT状态:A,B,C,D,E,F,4,8 ,1

我创建了一个包含所有患者状态[Tbl_Status]的表格。我想用表格(Tbl_Status)在表单上创建一个组合框,允许我按状态过滤。因此,如果我只想查看身份4中的患者,我可以过滤它然后移除过滤器,以便我可以回到所有记录。


有没有办法我可以编写组合框来执行此操作。如果我不需要使用VB,我还能做些什么来完成这项工作。如果无法完成,请告诉我。我不知道在VB中可以做什么或不能做什么。感谢您的任何反馈。



首先,感谢您清楚地解释了它可以让您更轻松地帮助您的问题。


是的,你可以这样做。根据您的表TblStatus创建一个名为cboStatus的组合框。


然后在组合框上创建一个After Update事件,如下所示:

展开 | 选择 | Wrap | 行号


哇!它工作得很好。非常感谢你。


我想知道有没有办法在删除过滤器后重置组合框。这不是什么大不了的事,我很高兴它正在工作。

谢谢!


$ b $哇哇!它工作得很好。非常感谢你。


我想知道有没有办法在删除过滤器后重置组合框。这不是什么大不了的事,我很高兴它正在工作。

谢谢!



在重置按钮代码中添加一行,如下所示:

展开 | 选择 | Wrap | 行号

Hi Experts,

I have searched all over the internet to find a solution but couldn?t find anything that made it easy for me.

I am a newbie to creating access DB (I see a lot of newbie?s come here) and I am trying to teach myself VB, but I am not there yet.

I have a DB in access 2003, on my main form [Patients] its source is from a
qry [Qry_All_Patiens], which is created from table[Tbl_All_Patients]. One of the fields available on the form is PTstatus. The patient can have several statuses

EX:

PT Status: A, B, C, D, E, F, 4, 8, 1

I created a table with all the different patient status [Tbl_Status]. I would like to create a combo box on the form with this table (Tbl_Status) that will allow me to filter by status. So if I wanted to look at just patients in status 4 I can just filter it and then remove the filter so that I can go back to all the records.

Is there a way I can code the combo box to do that. If I don''t need to use VB, what else can I do to get this done. If it can?t be done please let me know. I don?t know what can be done or cannot be done in VB. Thanks for any feedback.

解决方案

Hi Experts,

I have searched all over the internet to find a solution but couldn?t find anything that made it easy for me.

I am a newbie to creating access DB (I see a lot of newbie?s come here) and I am trying to teach myself VB, but I am not there yet.

I have a DB in access 2003, on my main form [Patients] its source is from a
qry [Qry_All_Patiens], which is created from table[Tbl_All_Patients]. One of the fields available on the form is PTstatus. The patient can have several statuses

EX:

PT Status: A, B, C, D, E, F, 4, 8, 1

I created a table with all the different patient status [Tbl_Status]. I would like to create a combo box on the form with this table (Tbl_Status) that will allow me to filter by status. So if I wanted to look at just patients in status 4 I can just filter it and then remove the filter so that I can go back to all the records.

Is there a way I can code the combo box to do that. If I don''t need to use VB, what else can I do to get this done. If it can?t be done please let me know. I don?t know what can be done or cannot be done in VB. Thanks for any feedback.

Firstly, thank you for clearly explaining the problem it makes it easier to help you.

Yes you can do this. Create a combo box called for example cboStatus based on your table TblStatus.

Then create an After Update event on the combo box as follows:

Expand|Select|Wrap|Line Numbers


Wow! it worked perfectly. Thank you very much.

I was wondering is there a way to reset the combo box after removing the filter. This is not a big deal, I''m really happy it is working.
Thank you!


Wow! it worked perfectly. Thank you very much.

I was wondering is there a way to reset the combo box after removing the filter. This is not a big deal, I''m really happy it is working.
Thank you!

Add a line to the reset button code as follows:

Expand|Select|Wrap|Line Numbers


这篇关于过滤表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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