使用VBA在Access 2010中使用的ID从不同的形式打开窗体 [英] Open a form using ID from a different form in Access 2010 using vba
本文介绍了使用VBA在Access 2010中使用的ID从不同的形式打开窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从另一种形式的按钮打开一个表格。与按钮,contracts_all本的形式,有一个域ID,我想打开一个包含与该ID信息的形式。第二种形式,合同,有更多的信息,并有按钮,允许特定合同的编辑。我设法得到的东西,但它给了我一个运行 - 时间错误2489.格式合同不开 在code是如下。先谢谢了。
私人小组Command74_Click()
ID = [表格]!Contracts_all![ID]
DoCmd.GoToRecord acDataForm,合同,ID
结束小组
解决方案
暗淡卢比作为记录
昏暗测试作为整数
昏暗varBookmark为Variant
DoCmd.OpenForm合同
设置卢比=窗体!Contracts.RecordsetClone
Rs.FindFirst([ID] ='&放大器;我[ID]放大器;!')
varBookmark = Rs.Bookmark
窗体!Contracts.Form.Bookmark = varBookmark
如果Rs.NoMatch然后
MSGBOX这并不存在此数据库中。
其他
结束如果
I am trying to open a form from a button in another form. The form with the button,contracts_all form, has a field ID and I want to open up the form that contains the information with that ID. This second form,contracts, has additional information and has buttons that allow editing of that particular contract. I have managed to get something but it's giving me a 'Run -time error 2489. Form contracts not open' The code is below. Thanks in advance.
Private Sub Command74_Click()
ID = [Forms]!Contracts_all![ID]
DoCmd.GoToRecord acDataForm, "Contracts", ID
End Sub
解决方案
Dim Rs As Recordset
Dim Test As Integer
Dim varBookmark As Variant
DoCmd.OpenForm "Contracts"
Set Rs = Forms!Contracts.RecordsetClone
Rs.FindFirst ("[ID] = '" & Me![ID] & "'")
varBookmark = Rs.Bookmark
Forms!Contracts.Form.Bookmark = varBookmark
If Rs.NoMatch Then
MsgBox "That does not exist in this database."
Else
End If
这篇关于使用VBA在Access 2010中使用的ID从不同的形式打开窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文