0

我不确定我是否为这个问题使用了正确的标题,但我会尝试问它。请耐心等待我是 Microsoft Access 的新手。

我正在为我公司的员工评论制作一个 MS-Access 数据库,我制作了表格,表格中的所有数据都将进入两个单独的表格。每次填写表格时,表格都通过相同的评级 ID 链接。

我有一个单独的表格,当您选择审查过的利益相关者的姓名时,它会在一个列表框中填写审查过他们的领导者的姓名、日期和评级 ID。如果您选择评级 ID,我使用 VB 将其打开,然后它将打开使用 DoCmd.OpenForm "FRM" 将数据放入其中的表单。

现在对于这个问题,我希望这一切都是可以理解的。我希望通过选择评级 ID 生成的表单重新填充为该特定 ID 输入到表中的所有信息。我需要做什么才能做到这一点?

4

2 回答 2

2

另一种选择是将表单基于表或查询(其RecordSource)并在打开表单时使用 Where 子句参数:

DoCmd.OpenForm "frmName", acNormal, , "[SomeID]=" & frmYours!ctlControlName

这样做的好处是可以单独打开表单,因为它只会显示来自其的所有数据RecordSource,而不会产生不需要的参数请求。

如果SomeID是文本,那么它的值需要用撇号引用:

DoCmd.OpenForm "frmName", acNormal, , "[SomeID]='" & frmYours!ctlControlName & "'"
于 2013-07-23T17:05:48.577 回答
0

There are various possible solutions to this.

The first one (and simplest) is to write a query in the RowSource property of your form with the appropriate data source, and include a filter field in that query that corresponds to the Id you are filtering:

select a.*
from [your table] as a
where a.[id] = forms!frmYourForm![theControlName]

That way, every time you open the form, it will show the appropriate data.

The second solution (a little more sophisticated) is to edit the RowSource property on run-time. In the code that opens the form, you can do something like this:

strSQL = "select a.* from [your table] as a where a.Id = " & theControlName.Value
DoCmd.OpenForm "theDetailedForm"
form_theDetailedForm.RowSource = strSQL
form_theDetailedForm.Requery

Hope this helps you

于 2013-07-23T17:01:03.637 回答