(VB.NET Visual Studio 2019)如何使父/子数据库通过多种表单工作?
我正在Visual Studio 2019(使用VB.Net)中创建表单,该表单连接到Microsoft Access数据库 从下图中,我有一个父表单(即客户数据库),其密钥ID是客户地址。当我按下底部的购买历史记录时,我可以打开一个子表单(即客户购买历史记录)。但是,我不知道要在子表单中编写哪些特定代码来过滤当前密钥ID的购买 在下面的示例中,当我按“购买历史记录”时,它会显示所有客户的购买情况,而不是WESTON路1011号的购买情况。我当前使用的代码是 “Me.TblCustomerPurchaseHistoryTableAdapter.Fill(Me.CustdataDataSet.tblCustomerPurchaseHostory)” 有谁能帮我过滤子数据库吗?我将非常感谢你的帮助。谢谢大家!(VB.NET Visual Studio 2019)如何使父/子数据库通过多种表单工作?,vb.net,visual-studio-2019,parent-child,Vb.net,Visual Studio 2019,Parent Child,我正在Visual Studio 2019(使用VB.Net)中创建表单,该表单连接到Microsoft Access数据库 从下图中,我有一个父表单(即客户数据库),其密钥ID是客户地址。当我按下底部的购买历史记录时,我可以打开一个子表单(即客户购买历史记录)。但是,我不知道要在子表单中编写哪些特定代码来过滤当前密钥ID的购买 在下面的示例中,当我按“购买历史记录”时,它会显示所有客户的购买情况,而不是WESTON路1011号的购买情况。我当前使用的代码是 “Me.TblCustomerPur
首先,需要为表适配器提供一个参数。单击表适配器并选择在子窗体上添加查询 它会提示出类似于 从CustomerPurchaseHistory(例如)中选择转换日期、客户、数量、价格 然后通过扩展查询添加参数 从CustomerPurchaseHistory中选择Transdate、Customer、Qty、Price,其中Customer=@Customer(例如),并在顶部将其命名为FillByCustomer 将创建一个新查询 那么您可能有类似于Me.tblcustomepurchasehistorytableadapter.FillByCustomer(Me.CustdataDataSet.tblcustomepurchasehostory,[在此处传递您的客户代码]) 在你的子表单上 声明一个类似于
Public CustomerCode as string
frmChildform.show
frmChildform.CustomerCode = [Your selected custoemrcode]
Me.TblCustomerPurchaseHistoryTableAdapter.FillByCustomer(Me.CustdataDataSet.tblCustomerPurchaseHostory, CustomerCode)
(以便您可以从父级传递参数)
在你的父母身上,你可以这样做
Public CustomerCode as string
frmChildform.show
frmChildform.CustomerCode = [Your selected custoemrcode]
Me.TblCustomerPurchaseHistoryTableAdapter.FillByCustomer(Me.CustdataDataSet.tblCustomerPurchaseHostory, CustomerCode)
在子窗体上的onformload事件之后,只需执行以下操作
Public CustomerCode as string
frmChildform.show
frmChildform.CustomerCode = [Your selected custoemrcode]
Me.TblCustomerPurchaseHistoryTableAdapter.FillByCustomer(Me.CustdataDataSet.tblCustomerPurchaseHostory, CustomerCode)
你能在GitHub上分享你的项目吗,或者在这里提供一些相关的代码?它将帮助其他人进行测试。