我一直在寻找关于stackoverflow的一些答案,但我没有找到任何答案。所以我决定问我自己的问题。
我正在用 VBA 编写一个搜索引擎,以便在我的数据库中找到合同。
这是我到目前为止所做的
Private Sub cmd_recherche_Click()
Dim strTable As String, strField As String, strCriteria As String, strSql As String
Dim Criter As Variant
If Me.listbox_search = "Num_contract" Then
Debug.Print Me.listbox_search
strTable = "AFN_LOT0"
strField = "NUMERO"
strCriteria = strTable & "." & strField & " Like """ & Me.txt_critere & """"
strSql = "SELECT DISTINCTROW " & strTable & "." & strField & "," & strTable & ".FORMULE," & strTable & ".DATE_EFFET," & strTable & ".DATE_ECHEANCE," & strTable & ".ETAT," & strTable & ".CODE_RESILIATION," & strTable & ".DATE_RESIL," & strTable & ".DATE_OPERATION"
strSql = strSql & " FROM " & strTable
strSql = strSql & " WHERE " & strCriteria & ";"
Me.lst_resultat.RowSource = strSql
Me.lst_resultat.Requery
End if
End sub
现在我希望能够双击列表框(lst_resultat)中的结果并打开另一个表单(F_InfosContract),其中将包含合同的所有信息(在单独的表中分派,全部由字段 ID_SOR 链接在一起)选择在列表框中。
我已经尝试过了,但它只会打开列表框中没有任何内容的表单..
Private Sub lst_resultat_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim Selection As String
Selection = lst_resultat.Value
stLinkCriteria = Selection
DoCmd.OpenForm "F_InfosContract", , , stLinkCriteria
End Sub
如果有人可以帮助我,那就太好了
对不起我的英语不好
万智牌