Access 2003 - 组合框查询问题 [英] Access 2003 - Combo Box Query Question

查看:93
本文介绍了Access 2003 - 组合框查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有两个标签的表单。一个称为新请求,第二个选项卡称为跟进。这些选项卡中的每一个都具有来自查询的字段,该查询使用两个表上的主键链接两个表(新请求表和后续表)作为跟踪。 跟踪 field是一个文本框,由用户在表单的第一个选项卡(新请求)上输入。


我希望用户转到第二个选项卡并选择一个组合显示所有可用跟踪的框用户输入的值。然后,当他们选择了其中一个值时,第二个选项卡将刷新并显示用户输入的关于跟进表的字段。我在使用具有查询记录源的表单时遇到了麻烦。我非常感谢帮助,因为我一直在寻找这个答案。看起来很简单。我是Access的新手,所以VBA对我来说很难。谢谢!

I have a form that has two tabs. One is called New Request and the second tab is called Follow Up. Each of these tabs have fields on it that come from a query that has linked two tables (New Request table and Follow up Table) using the primary key on both tables as "Tracking." The "Tracking" field is a text box that is input by a user on the first tab (New Request) on the form.

I would like the user to go to the second tab and select a combo box that shows all available "Tracking" values that the user has input. Then when they have selected one of these values, the second tab refreshes and displays the fields for the user to input in regards to the Follow Up table. I''m having trouble doing this with a form that has a record source of the query. Help would be much appreciated as I''ve been looking everywhere for this answer. It seems like it would be simple. I''m kind of new to Access so VBA is hard for me. Thanks!

推荐答案

嗨Chad,


欢迎来到字节!


你在标签上有子表格吗?我最近做了类似的事情,但我使用一个组合框与一个子表单来过滤/重新查询子表单。但是,我试图根据主窗体上的信息来过滤子窗体。当组合框发生变化时,您是否尝试在与新请求和跟进相关的表单上获取所有内容?


这是我的设置如何为您提供你可能会根据你想要完成的事情来调整你的表格。


我的主要表格和标签1上的信息显示了一般信息。病人。选项卡2上的信息用于患者的其他信息,并且位于具有不同查询的子表单中。在第二个选项卡上(而不是在子窗体中)有一个组合框,用户可以单击该组合框以重新查询子窗体。因此,如果用户将组合框值更改为允许,则子表单将重新查询并仅显示Admit info ...如果用户将组合框更改为Discharge子表单将重新查询并仅显示Discharge信息。


我创建了一个名为cboAudit的组合框,并将其放在第二个选项卡上。我在AfterUpdate事件中输入以下代码:

Hi Chad,

Welcome to Bytes!

Do you have subforms on the tabs? I recently did something similar, but I was using a combo box in conjunction with a subform to filter/requery the subform. However, I was trying to get the subform to filter based on info on the main form. Are you trying to get everything on the form related to the New Request AND the Follow Up to requery when the combo box changes?

Here''s how mine was setup to give you an idea that you may be able to tweak to modify your form based on what you''re trying to accomplish.

My main form, and the info on tab 1, shows general information for a patient. The info on tab 2 is for additional information for the patient and is in a subform with a different query. There is a combo box on the 2nd tab (not in the subform) that the user can click to requery the subform. So if the user changes the combo box value to "Admit" the subform will requery and only show "Admit" info...if the user changes the combo box to "Discharge" the subform will requery and only show "Discharge" info.

I created a combo box, called cboAudit, and placed it on the 2nd tab. I entered the following code in the AfterUpdate event:

展开 | 选择 | Wrap | 行号


感谢您的回复!我正在使用子表单,它确实可以显示跟踪的后续字段。在组合框中选择的数字。我遇到的问题是这个 - 子窗体上的一个字段叫做状态。当用户输入状态时,作为已关闭,我希望组合框不显示跟踪数字了。我试图将状态的标准放在一起。在后续查询(这是子窗体的记录源)但是我无法刷新组合框。您提供的代码会这样做吗?再一次,对不起,代码对我来说非常陌生,再次感谢您花时间帮助我。
Thanks for the reply! I was using a subform and it did work on displaying the follow up fields for the "Tracking" number that was selected in the combo box. The problem I ran into is this - One of the fields on the subform is called "Status." When the user inputs the "Status" as "Closed," I want the combo box not to show that "Tracking" number anymore. I attempted to put the criteria for "Status" in the Follow up query (this is the record source of the subform) however I couldn''t get the combo box to refresh. Will the code that you provided do that? Again I''m sorry, code is very foreign to me and thanks again for taking the time to help me.


是子窗体上的跟踪编号组合框还是选项卡上的控制?回答者会改变下面的代码,所以我假设组合框也在子窗体中。如果它有所不同并且您无法修改代码,请告诉我。


我认为您可以创建一个查询,仅显示具有状态的记录。不等于已关闭。为了简单起见,我将把这个查询称为qryStatus,尽管你可以随意命名它(只需确保在下面的代码中更改它)。我会将组合框的行源设置为没有任何方式,您可以在状态时以编程方式设置它。值变化。


在状态的BeforeUpdate事件中字段,您可以使用以下代码:
Is the Tracking number combo box on the subform or is it on the tab control? The answser will kind of change the code below, so I''m going to assume that the combo box is also in the subform. If it''s different and you have trouble modifying the code, let me know.

I think you can create a query that shows only the records that have "Status" not equal to "Closed." To make things easy, I''m going to refer to this query as qryStatus, although you can name it whatever you want (just be sure to change it in the code below). I would set the row source for the combo box to nothing that way you can programmatically set it when the "Status" value changes.

In the BeforeUpdate event for the "Status" field, you can use the following code:
展开 | 选择 | Wrap | 行号


这篇关于Access 2003 - 组合框查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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