MS Access - 打开从前一个表单中获取字段值的表单 [英] MS Access - open a form taking a field value from a previous form
问题描述
我在MS Access数据库中有一个表单,其中列出了为新电力线咨询的所有土地所有者。在每一行的末尾是一个按钮,打开另一种形式,显示所有咨询,提供的详细信息等。
I have a form in an MS Access database which lists all the landowners consulted with for a new electricity line. At the end of each row is a button which opens another form, showing the details of all consultation, offers made etc.
我试图在MS Access中使用vb采用contactID并自动将其放入详细信息表单中的字段中,以便自动弹出土地所有者的咨询详细信息。我不是一个vb程序员(我有一个大部分在Java和我目前工作作为一个GIS分析师,但它是一个小公司,所以我被要求获得一个Access数据库工作)。
I am trying to use vb in MS Access to take the contactID and automatically put it in a field in the details form, so that landowner's consultation details will pop up automatically. I am not a vb programmer at all (I have a comp sci degree mostly in Java and I'm currently working as a GIS analyst but it's a small company so I've been asked to get an Access database working).
我想用vb和访问方式说出
[detailsForm]![contactID] = [landownerlist]![ID]
快乐。然后我可以看到,如果我在正确的轨道,如果它实际上工作!我上面的内容实际上不工作。它不会编译。
I want to say [detailsForm]![contactID] = [landownerlist]![ID] in a way that vb and access will be happy with. Then I can see if I'm on the right track and if it will actually work! What I have above does not actually work. It won't compile.
来自Kaliana
推荐答案
如果您要打开表单一个新记录并在其中设置ID,可以使用Openargs,Openform的参数:
If you wish to open a form to a new record and to set the ID there, you can use Openargs, an argument of Openform:
DoCmd.OpenForm "FormName",,,,acFormAdd,,Me.ID
打开的表单还需要一些代码: p>
The opened form would also need some code:
If Me.Openargs<>vbNullstring Then
Me.Id = Me.Openargs
End If
也可以找到:
Forms!LandownersList.Recordset.FindFirst "ID=" & Me.ID
或填写值:
Forms!LandownersList!Id = Me.ID
在调用表单上打开的表单。
on the form being opened from the calling form.
这篇关于MS Access - 打开从前一个表单中获取字段值的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!