2016-12-13 61 views

回答

0

首先,编写获取要填充到右边的字段中的数据的功能。有它采取的ID作为参数,如:

public function FillWithData(recordId as int) 
dim s as string 
dim r as new adodb.recordset 
s = "SELECT * FROM MyTable WHERE IdField =" & recordId & ";" 
r.Open s, CurrentProject.Connection, adOpenDynamic, adLockReadOnly, dbSQLPassThrough 
Exit Function  
End Function 

其次,在Click事件添加到列表中。

Private Sub myList_Click() 
dim id as int 
id = myList.Column(1) 'the number here is the index of the column that contains the record id in the RowSource of the List. 
Call FillWithData(id) 
Exit Sub 
End Sub 
相关问题