Microsoft Access-记录表单加载 [英] Microsoft Access - Record Form Load
问题描述
我很好奇,是否有可能在我以一种形式加载记录时选择为该记录添加报价,所以我选择添加报价(按钮),从而将我带到报价页面.然后,我希望该表单自动加载以前在其他表单中选择的记录.
I am curious whether it is possible that when i load a record in one of my forms and i choose to add a quote for that record selected, so i choose add quote (button) which takes me to my quote page. i would then like the form to auto load the record i had previously selected in the other form.
客户表格:
报价表: 这是数据流: 选定的记录(添加作业")>单击添加项目"按钮>项目列表"加载>然后自动加载先前在添加作业"中选择的记录.
Quote Form: Here is the data flow: Record Selected ("Add Job") > Click "Add Items" button > "Items List" loads > the record i previously selected in "Add Job" is then auto loaded.
需要加载的字段是项目ID"& 客户名称"
the feild that will need loading are "Project ID" & "Client name"
推荐答案
使用DoCmd.OpenForm
方法的自变量
Use OpenArgs
argument of the DoCmd.OpenForm
method
- 单击
Add Quotes
按钮打开报价"表单时,通过openArgs参数发送详细信息/链接的ID. - 在Quotes表单加载事件中,您可以使用
Me.OpenArgs
获取传递的详细信息
- When you click
Add Quotes
button to open Quotes form, send the details/linked ID via openArgs parameter. - In Quotes form load event, you can get the details passed using
Me.OpenArgs
请参见下面的示例代码
在添加报价"按钮上单击
On Add Quotes button click
Private Sub AddQuotes_Click()
DoCmd.OpenForm "frmQuotes", OpenArgs:=me.ClientID
End Sub
报价表
Private Sub Form_Load()
Dim varArgs
varArgs = Me.OpenArgs
'Fill the controls with recordset data
If Not IsNull(varArgs) Then
With CurrentDb.OpenRecordset("SELECT * FROM tblClients WHERE ClientID = " & varArgs, dbOpenForwardOnly )
Me.ClientID = !ClientID
Me.ClientName = !ClientName
Me.ClientAddress = !ClientAddress
Me.ClientPhone = !ClientPhone
Me.ClientEmail = !ClientEmail
.Close
End With
End If
End Sub
这篇关于Microsoft Access-记录表单加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!