是否有可能点击的报告记录使用VBA在Access中打开相关表格 [英] Is it possible to click on a report record to open relevant form in Access using VBA

查看:100
本文介绍了是否有可能点击的报告记录使用VBA在Access中打开相关表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个报告,作业/任务的详细信息,也有助于广大朝着这个报告中的数据的一种形式。由于报告是观察数据的照片放大一个不错的方式,而形式是编辑数据的最佳方式,我希望能够点击一个行,有它在打开相关记录表单视图。

I have a report with details of jobs/tasks, and also a form which contributes the majority of the data towards that report. Given that a report is a nice way of looking at the larger picture of the data, and a form is the best way of editing data, I would like to be able to click on a row, and have it open up the relevant record in the form view.

有谁知道如何通过VBA做到这一点?在我看来,它应该是可能的,虽然对象的我在Access中的知识是有限的。

Does anyone know how to do this through VBA? In my mind it should be possible, though my knowledge of objects in Access is limited.

更新

我已经实现了以下code我报告:

I've implemented the following code for my report:

Private Sub Edit_Click()

  Dim EntityName As String
  Dim DocName As String

  DocName = "Entity: Overview"

  strWhere = "[Entity Name]='" & Entity & "'"
  DoCmd.OpenForm DocName, acNormal, , EntityName

End Sub

它成功打开正确的形式,同时也抓住了正确的实体名称,但它是不正确的过滤。我看不到的问题是与code什么。

It successfully opens the correct form, and it also grabs the correct entity name, however it isn't filtering properly. I can't see what the issue is with the code.

推荐答案

在你的 Edit_Click()过程中,你有的entityName WhereCondition 的参数的OpenForm

In your Edit_Click() procedure, you have EntityName as the WhereCondition parameter to OpenForm.

  DoCmd.OpenForm DocName, acNormal, , EntityName

不过,你有没有指定任何的entityName ,所以它是一个空字符串。我认为你应该使用 strWhere WhereCondition 的。

However, you haven't assigned anything to EntityName, so it's an empty string. I think you should use strWhere as the WhereCondition.

Private Sub Edit_Click()
  Dim strWhere As String
  Dim DocName As String

  DocName = "Entity: Overview"
  strWhere = "[Entity Name]='" & Me.Entity & "'"
  DoCmd.OpenForm DocName, acNormal, , strWhere
End Sub

我以为实体是一个控件的名称,而这也正是你得到一个值来构建 strWhere 。如果通过实体的名称的报告无法控制,那么code不会,如果有一个实体<工作,即使/ code>在原来的查询。

I assumed Entity is the name of a control, and that's where you get a value to build strWhere. If there is no control in the report by the name of Entity, then the code won't work even if there is an Entity in the original query.

这篇关于是否有可能点击的报告记录使用VBA在Access中打开相关表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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