0
我希望能够从列表框和组合框中打开记录(查找记录)我的形式。我想用它们作为导航的一种手段。MS Access:从组合/列表框中转到表单上的记录
伊夫包括图片:My Form and navigation set up
我希望能够从列表框和组合框中打开记录(查找记录)我的形式。我想用它们作为导航的一种手段。MS Access:从组合/列表框中转到表单上的记录
伊夫包括图片:My Form and navigation set up
首先,编写获取要填充到右边的字段中的数据的功能。有它采取的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