帮助列表框 [英] Help with a list box

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

问题描述

我需要帮助找出一些东西。我不确定我是否会朝着正确的方向前进。我想要完成的是以下内容。

我有一张桌子

有id,discrip和2个日期字段。我在

主表单上填写了这个信息

。 Id和date字段在表单中绑定在一起。我是

试图获取

descrip字段,以便在列表框下显示在我的主窗体中。我有一个
创建了一个sql查询来试图完成这个。我可以为每个id提供多行

信息。这就是我试图在

列表框中显示的原因。我遇到的问题是我无法找到

当前页面的特定id我在表单中。它提示我

id。如果我输入id,列表框将显示正确的信息。我想

,看看我在我的表单中的哪个页面从那里拿到id并且

相应地填写列表框。当我更换床单时,它将自动更新
。我在下面粘贴了sql查询。我真的很想知道如何使这项工作有任何见解。提前谢谢。

Dan

SELECT [预订]。[网站],[预订]。[预订],

[预订] 。[reservationsid]

FROM reserve

WHERE(([reserve]。[reservationid])=([预订]。[reservationsid]));

I need some help figuring something out. I''m not sure if I heading in
the correct direction. What I''m trying to accomplish is the following.
I have a table that
has id, discrip, and 2 date fields. I am populating this information
from a sub from on a
main form. The Id and date fields are tied together in the forms. I am
trying to get the
descrip field to show up in my main form under a listbox. I have
created a sql query to try to accomplish this. I can have multiple
lines of information for each id. That''s why I''m trying to show in
list box. The problem I am having is I cannot get it to look for
specific id of the current page I''m on in the form. It prompts me for
id. If I enter the id the list box displays correct info. I would like
for it to see what page I''m on in my form take the id from there and
fill the list box accordingly. When I change sheets it would
automatically update. I have pasted sql query below. I would really
appreciate any insight on how to make this work. Thanks ahead of time.
Dan
SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve
WHERE (([reserve].[reservationid])=([reservations].[reservationsid]));

推荐答案

Dan,我不确定我是否完全理解你的情况,但是我会b / b
会尽力帮助使用一些常规列表框信息。


要填充绑定到表的列表框,您只需将

记录添加到表中,然后调用ListBox .Refresh()方法。如果您的列表框位于主窗体上,但是您想要从子窗体中填充
,那么这个

可能很有用。如果您对

列表框进行了很多更新,这可能会产生很多开销。


您也可以通过编程方式填充列表框。一种方法是:

这里,lstBox将指示你的列表框,frmMain将表明你的

主表格。


表格!frmMain!lstBox.Items.Add(" info to want to quot;)

Dan, I''m not sure I completely understand the situation you have, but I
will try to help with some general listbox information.

To populate a listbox that is bound to a table, you can simply add
records to the table and then call the ListBox.Refresh() method. This
may be useful if your listbox is on the main form but you want to
populate it from a subform. If you are doing many updates of the
listbox, this can have a lot of overhead.

You can also populate the listbox programmatically. One way is such:
Here, lstBox will indicate your listbox, and frmMain will indicate your
main form.

Forms!frmMain!lstBox.Items.Add("info you want to add")


在您的查询中:


SELECT [reserve]。[site],[reserve]。[reservationid],

[预订]。[reservationsid]

FROM reserve

WHERE(([reserve]。[reservationid])=([预订]。[reservationsid]));


保留表格名称或是否应该是来自

联合表的字段。我不确定这是否是您的根本问题,但是

您的查询现在会给出错误,因为FROM子句中不存在预订表

。我希望您的查询看起来像

更像是:

SELECT [reserve]。[site],[reserve]。[reservationid],

[预订]。[reservationsid]

FROM保留,预订

WHERE(([reserve]。[reservationid])=([预订]。[ keepid]);





SELECT [reserve]。[site],[reserve]。[reservationid],
[预订]。[reservationsid]

来自预订INNER JOIN预订

ON(([reserve]。[reservationid])=([预订]。 [reservationsid]));


另外,你真的不需要在

结果集中有两个reservationid字段,因为它们是等价的。 />

同样,这可能不会导致列表框出现问题,但它可能会对它产生影响。

In your query:

SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve
WHERE (([reserve].[reservationid])=([reservations].[reservationsid]));

Is reservations the form name or is it supposed to be a field from a
joined table. I am not sure if this is your root problem or not, but
your query would give an error right now since the reservations tables
does not exist in the FROM clause. I would expect your query to look
more like:

SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve, reservations
WHERE (([reserve].[reservationid])=([reservations].[reservationsid]));

OR

SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve INNER JOIN reservations
ON (([reserve].[reservationid])=([reservations].[reservationsid]));

Also, you really would not need to have two reservationid fields in the
result set, since they are equivalent.

Again, this may not be causing the issue with the list box, but it
might be contributing to it.


也许我没有说清楚。我想要一个列表框,从表格中的表格中显示

信息。该表不是

主表格正在推动的表格。我希望列表框能够从

中查看有效记录的表格,并且只显示

信息,其中2个预订ID是=。列表框将工作

,如果我键入reservationid,但它不会从活动表单中获取

页面,就像我想要的那样。希望这个好人解释问题。

Perhaps Im not making myself clear. I want a list box to show
information from a table in a form. The table is not the table that
main form is driving. I want the list box to see the reservationid from
the form on which ever record is active, and to show only the
information where the 2 reservation id''s are =. The list box will work
if I type in reservationid, but it won''t get it from the active form
page like I want. Hopefully this bettrer explains problem.


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

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