本文介绍了访问:从另一个表格自动填充表单上的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为[LastNameC]的组合框

I have created a Combo Box called [LastNameC]

SELECT [Vendeurs]。[VendeurID],[Vendeurs]。[姓名],[Vendeurs]。[名字来自Vendeurs;

SELECT [Vendeurs].[VendeurID], [Vendeurs].[Last Name], [Vendeurs].[First Name] FROM Vendeurs;

您选择用户的姓氏,以及根据组合框中选择的名称自动填充名字的文本框

where you select the users last name and a text box that autofills the first name based on the name selected in the combobox

Me.FirstName = Me.LastNameC.Column(2)

Me.FirstName = Me.LastNameC.Column(2)

我想添加一个基于组合框选择自动更新的文本框,以显示每个成员所属团队的名称to - 关系是在成员[Vendeurs]和团队[Equipe]之间创建的 - 我有一个tblEquipe,它与Vendeurs talbe中的[FKEquipeID]的主键
[EquipeID]关系 -  和[Equipe] ]名称

I want to add a text box that auto updates based on Combo Box selection to show the name of the team each member belongs to - the relationships are created between members [Vendeurs] and team [Equipe] already - I have a tblEquipe which has primarykey [EquipeID] relationships with [FKEquipeID] in the Vendeurs talbe - and the [Equipe] for the name

谢谢

推荐答案

Private Sub LastNameC_AfterUpdate()

Dim db作为数据库

Dim rst作为记录集

设置db = CurrentDb

Private Sub LastNameC_AfterUpdate()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb

'从Vendeurs获取组合框中所选值的FKEquipeID

FKEIDfromVendeur = LastNameC.Value

strSQL ="从Vendeurs中选择FKEquipeID,其中VendeurID =" &安培; FKEIDfromVendeur

设置rst = db.OpenRecordset(strSQL)

'get FKEquipeID from the Vendeurs for the selected value in the combo box
FKEIDfromVendeur = LastNameC.Value
strSQL = "Select FKEquipeID from Vendeurs where VendeurID = " & FKEIDfromVendeur
Set rst = db.OpenRecordset(strSQL)

'从tblEquipe获取Equipe>
strSQL ="从tblEquipe中选择Equipe其中EquipeID =" &安培; rst![FKEquipeID]

Set rst = db.OpenRecordset(strSQL)

'get Equipe from tblEquipe
strSQL = "Select Equipe from tblEquipe where EquipeID = " & rst![FKEquipeID]
Set rst = db.OpenRecordset(strSQL)

'在EquipeT文本框中显示Equipe

EquipeT .SetFocus

EquipeT.Value = rst![Equipe]

'display Equipe in the EquipeT text box
EquipeT.SetFocus
EquipeT.Value = rst![Equipe]

End Sub


这篇关于访问:从另一个表格自动填充表单上的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:38