0
私のフォーム上のリストボックスとコンボボックスからレコードを開くことができます。私のフォーム。私はそれらをナビゲーションの手段として使いたいと思う。 My Form and navigation set upMS Access:コンボ/リストボックスからフォームのレコードに移動
私のフォーム上のリストボックスとコンボボックスからレコードを開くことができます。私のフォーム。私はそれらをナビゲーションの手段として使いたいと思う。 My Form and navigation set upMS Access:コンボ/リストボックスからフォームのレコードに移動
まず第一に、あなたは右のフィールドに移入するデータを取り出す関数を書く:
アイブ氏は、画像が含まれています。次のように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
第2に、On 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