1)从ListBox查询参数? 2)组合框查询参数? [英] 1) Query Parameter From ListBox? 2) Combo Box Query Parameter?

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

问题描述

Hello Guys。在一个表单中,我创建了一个列表框,用于查找表格的值。


我想要:


1)

..创建一个查询,其中需要一个参数才能加载。

但我不想写参数,我想从列表框中选择一行并在之后单击一个按钮,查询将自动将列表框的当前值作为所需参数,然后加载查询。

(输入参数的输入框将不会显示,因为数据库将自动获取所需参数的列表框值)。


这是有可能?我怎么能这样做?

请告诉我完成此操作的整个过程(从查询创建到VBA代码)。


2)然后我根据此查询创建了一个表单。

我想要一个组合框来查找表单的当前记录。

我意识到,如果我在表单查询中插入了一个组合框。在加载之前询问参数时,需要在单击组合框时重新写入参数,以便显示当前值。

所以我想知道是否有一种方法,在加载表单查询后,组合框获取列表框中所选行的参数,以便不需要写参数。


如果有人可以帮助我,我会非常感激。

感谢高级。

Hello Guys. In a form I created a listbox which looks up the values of a table.

I want:

1)
..to create a query where a parameter will be needed in order to be loaded.
But I do not want to write the parameter, I want to select a row from the listbox and after clicking in a button, the query to automatically take the current value of listbox as the needed parameter and then to load the query.
(The Inputbox for "Enter Parameter" will not be showed as the db will automatically takes the listbox value for the required parameter).

Is this possible ? And How can I do it ?
Please tell me the whole procedure to do this (from the query creation to VBA code).

2) Then I created a form based on this query.
I want to have a combo box to look up the current records of the form.
As I realised, If I inserted a combo box in a "form query" that ask for a parameter before it loads, you need to re-write the parameter when you click to combo box in order for the current values to be showed.
So I would like to know if there is a way, after loading the "Form query", the combo box to take the parameter of the chosen row in the listbox in order not to be needed to write the parameter.

If someone can help me, I would really appreciate it.
Thanks in advanced.

推荐答案

在您描述的事项中,我喜欢使用这种逻辑来动态创建查询,如反对填充参数值:
In matters such as you describe, I like to use this logic whereby a Query is dynamically created, as opposed to populating Parameter Values:
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


两种适用于主窗体和ComboBox的方法是:
Two ways, that should work both for your main form and your ComboBox, are :
  1. 正如ADezii所解释的那样,即时构建SQL。
  2. 在查询中包含对Listbox的引用(或SQL)串)。当前所选项目的值将是引用返回的值。



如你所描述的,我喜欢使用这种逻辑来动态创建Query,而不是填充参数值:
In matters such as you describe, I like to use this logic whereby a Query is dynamically created, as opposed to populating Parameter Values:
展开 | 选择 | 换行 | 行号


这篇关于1)从ListBox查询参数? 2)组合框查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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