根据组合框预定义值过滤Microsoft访问记录 [英] filtering microsoft access records based on combo box predefined values

查看:78
本文介绍了根据组合框预定义值过滤Microsoft访问记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Microsoft Access数据库.它具有一个客户表和每个客户的输入日期.我还有一个包含所有客户及其信息的表格.

I have a Microsoft Access database. It has a customers table and a date of entry of each customer. I also have a form which includes all customers and their info.

我想制作一个组合框(下拉框),其中应包含一年中的月份(一月,二月,三月,四月等).当用户从组合框中选择4月时,记录表中只会显示该月添加的记录.

I want to make a combo box (drop down box) that would include months of the year (January, February, March, April, etc.). When the user chooses April from the combo box, only the records which were added in that month will show up in the records table.

可以做到吗?我已经尝试这样做至少三天了,但是没有运气.

Can this be done? I have been trying to do this for at least 3 days but no luck..

亲切的问候.

推荐答案

本质上,您需要一个下拉字段,该字段应用过滤功能以按月份过滤相应的记录.根据是否使用子窗体执行以下操作.

Essentially, you need a drop down field that applies a filter functionality to filter corresponding records by the month. Do the following depending on if you are using a subform or not.

主表单(无子表单)-使用ApplyFilter

  1. 创建一个组合框,或者使用输入的所有12个月的值列表选择,或者使用月份"表中的数据(使用隐藏或未隐藏的月份号).
  2. 使用命令ApplyFilter为AfterUpdate或OnClick按钮事件创建宏或VBA例程.

宏:ApplyFilter FilterName: (leave blank), Where Condition: ="=[Record Month Field]='" & Forms!MainForm!FilterMonthCombo & "'", Control Name: (leave blank)

VBA:DoCmd.ApplyFilter , "[Record Month Field]='" & Me.FilterMonthCombo & "'"

主窗体(带有子窗体)-使用RecordSource

  1. 创建一个组合框,或者使用输入的所有12个月的值列表选择,或者使用月份"表中的数据(使用隐藏或未隐藏的月份号).
  2. 为AfterUpdate或OnClick按钮事件创建VBA例程,以动态过滤子窗体的RecordSource:

VBA:Forms!MainForm!Subform.Form.RecordSource = "SELECT * FROM Records WHERE [Record Month Field]='" & Forms!MainForm!FilterMonthCombo & "'"

这篇关于根据组合框预定义值过滤Microsoft访问记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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