列表框转到记录 [英] List Box Go To Record

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

问题描述

大家好,

我有一个表格的数据库,我有一个列表框,用作一种''菜单''(即它列出了数据库中的所有记录)。任何人都可以帮我设置代码,这样如果我双击列表框中的记录标题,表单将跳转到相应的记录?我已经尝试了各种DoCmd.GoToRecord代码,但我肯定做错了,因为它永远不会有效。


换句话说,代码必须识别我的记录标题点击列表框并转到带有相应标题的记录。


感谢你的帮助!

解决方案

< blockquote>您是否尝试转到表单上的选定记录?你的表格是基于查询还是表格?


想到几个一般的建议:


1.更改列表框到组合框(在表单设计视图中右键单击并选择更改为)。

2.在属性对话框中,确保将绑定源设置为包含RecordID的字段。

3.使用这种代码:DoCmd.OpenForm" [2ndformname]",acNormal ,," RecordID =" &安培;我![comboboxname] .Value


如果您是想在桌子上查找记录,我建议从长远来看,你会发现它更容易创建基于表的查询,以及基于查询的表单。如果你喜欢这种类型的视图,总是可以在数据表模式下查看表格。


你可能已经知道了这一切!但希望这些建议有所帮助......


为了清楚起见,DoCmd.OpenForm代码行将在你的组合框的After Update事件下。


谢谢你的回复,斯科特。我尝试了你的代码,但它实际上做了别的事情(它改变了我正在查看的记录中的RecordID到组合框中选择的ID)。让我给你一些更详细的信息:


我在表格标题中有一个列表框。我的表单列出了基础表中所有记录的标题。表单本身基于表格。


我希望能够点击顶部列表框中的标题,并将表单跳转到相应的记录。 />

如果有必要,我绝对可以将列表框更改为组合框。


非常感谢您的帮助!非常感谢!


Hi everyone,

I have a database with a form on which I have a listbox which is used as a kind of ''menu'' (i.e. it lists the titles of all the records in the database). Can anyone help me set up a code so that if I double-click on a record title in the listbox, the form will jump to the corresponding record? I''ve tried various DoCmd.GoToRecord codes, but I am definitely doing something wrong, because it never works.

In other words, the code has to recognize the record title I''m clicking in the listbox and go to the record with the corresponding title.

Thanks for your help in advance!

解决方案

Are you trying to go to the selected record on a form? And are your forms based on a query or table?

A couple of general suggestions come to mind:

1. change the list box to combo box (in form design view right-click and choose change to).
2. In the properties dialog, make sure the bound source is set to the field that includes your RecordID.
3. Use this kind of code: DoCmd.OpenForm "[2ndformname]", acNormal,,"RecordID = " & Me![comboboxname].Value

If you are instead trying to look up the record in a table, I would suggest that in the long run you''ll find it easier to create a query based on the table, and form based on the query. The form can always be viewed in Datasheet mode if you prefer that type of view.

You likely know all this already! But hope the suggestions help...


For clarity the DoCmd.OpenForm code line will go under the After Update event of your combo box.


Thanks for your reply, Scott. I tried your code, but it actually does something else (it changes the RecordID in the record I''m viewing to the ID selected in the combobox). Let me give you some more detail:

I have a listbox in the "form header" of my form that lists the titles of all records in the underlying table. The form itself is based on a table.

I would like to be able to click on a title in the listbox at the top and have the form jump to the corresponding record.

I can definitely change the listbox to a combobox, if necessary.

Thank you very much for your help! It is much appreciated!


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

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