在 MS Access 2007 中通过单击打开表单按钮来显示特定记录不起作用

发布于 2024-12-08 01:09:31 字数 1021 浏览 0 评论 0原文

假设我在 MS Access 中有 2 个表:

关于为某公司工作的一些人员的表:

在此处输入图像描述

以及关于的表一些公司持有的一些项目:

在此处输入图像描述

我还有两个相应的表格表格(问题在大按钮):

在此处输入图像描述 在此处输入图像描述

我在互联网上搜索了解决方案,我尝试了一些,但没有达到预期的目标,这里有两个:

DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]

DoCmd.OpenForm "Project_readonly", , , _
"People_readonly.[Project_ID] = '" & _
Project_readonly.id & "'"

另外,在搜索时,我发现许多其他人也有同样的问题,他们尝试了一些查询,但不起作用。有些人还说 Wizard 有一些错误,因此它无法生成工作代码。所以我想问一下是否可以填写我所附BD文件的代码并上传到这里?将非常感谢!这是文件: http://www.sendspace.com/file/pf9tov 。如果您提供您的解决方案,如果您解释它是如何工作的,那就太好了!

另外,请提供一个很好的教程,它清楚地解释了 Visual Basic,没有过度膨胀,并且专门针对 MS Access 使用,我已经找到了一些,但它们是针对 Windows 窗体的。

Assume I have 2 tables in MS Access:

Table about some people which work for some company:

enter image description here

And table about some projects which some company holds:

enter image description here

I also have two corresponding forms for tables (the question is typed on the big button):

enter image description here
enter image description here

I have searched in internet for a solution, I tried some, but haven't achieved a desired goal, here are two of them:

DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]

DoCmd.OpenForm "Project_readonly", , , _
"People_readonly.[Project_ID] = '" & _
Project_readonly.id & "'"

Also while searching I found many other people having the same problem, they try some queries, but they don't work. Some also say that Wizard has some errors, so that it doen't produce working code. So I ask if is it possible that one filled the code for the attached BD file of mine and upload it here? Would be much thanks! Here is the file: http://www.sendspace.com/file/pf9tov . If you provide your solution, it would be also very good if you explain how it works!

Also please provide a good tutorial which exmplains Visual Basic clearly, whithout overbloat and specifically for MS Access usage, I have found some, but they are for windows forms.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戈亓 2024-12-15 01:09:31

我认为问题出在这里:

DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]

使用 People_readonly 表单的记录源作为 Project 表,您希望WhereCondition 参数选择其 Id 值与当前表单的 Project_ID 值匹配的 Project 行。

如果这听起来不错,请尝试以下方式:

DoCmd.OpenForm "Project_readonly", , , "Id = " & Me!Project_ID

I think the problem is here:

DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]

With the Record Source for your People_readonly form as the Project table, you want the WhereCondition parameter to select the Project row whose Id value matches the current form's Project_ID value.

If that sounds right, try it this way:

DoCmd.OpenForm "Project_readonly", , , "Id = " & Me!Project_ID
粉红×色少女 2024-12-15 01:09:31

我刚刚解决了一个类似的问题,可能会对你有所帮助。在链接到表格的表单中,我创建了一个按钮,可以前进到当天的表单/记录。

-创建按钮

-使用 SearchForRecord 操作

-对象类型:表(因为我正在引用表中的信息)

-对象名称:*引用的表的名称

-记录:第一个(因为您正在查找与您的值匹配的第一条记录正在表中搜索)

-Where Condition: [Date]= Date() (当字段[DATE]与当前日期匹配时进行搜索)

您可以尝试将对象类型更改为 Form,将对象名称更改为您的表单名称,然后改变where 条件为 [Project_ID]= 2 。希望这有帮助。

I just solved a similar problem which may help you. In a form linked to a table, I created a button that advances to the current day's form/record.

-Created button

-Used SearchForRecord action

-Object type: Table (because I was referencing information in a table)

-Object name: *the name of the table referencing

-Record: First (because you're finding the first record matching the value you're searching for in the table)

-Where Condition: [Date]= Date() (searching for when the field [DATE] matches the current date)

You can try changing the object type to Form and object name to your form name, then change the where condition to be [Project_ID]= 2 . Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文