如何在 ADODB 查询中从列表中声明变量?

玛丽

我有一个包含 100 个变量的选择列表:我想单击此列表并在我的 ADODB 查询中使用 tis 变量:我不知道如何从列表中声明所选变量(例如,如果我选择 LFG - CORTAGE - 999) 在查询中。

我的清单:.com/cfm5G.png

法尼杜鲁

请复制工作表代码模块中的下一个代码并开始更改下拉选项。但是您的代码存在问题:未声明和定义参数“cnn_Pegase”。

Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0, 0) = "E15" Then
        N_CG_bulletin_de_souscription Target.Value
    End If
End Sub

Sub N_CG_bulletin_de_souscription(strQ As String)
    'Please, note that the parameter 'cnn_Pegase' is not declared and defined.
    'Properly declare it and give to it the necessary value, before running the code...
    Dim RECSET As New ADODB.Recordset
    RECSET.Open "select cond_gene.s_no_cg from db_dossier sousc, db_protocole proto, db_tiers tiers, db_cond_gene cond_gene, dr_protocole_cg protocole_cg, db_personne pers, db_contrat cont " & _
                " where sousc.no_police = '" & strQ & "' and sousc.cd_dossier = 'SOUSC' and sousc.lp_etat_doss not in ('ANNUL','A30','IMPAY') and sousc.is_dossier = cont.is_dossier and cont.is_cg = cond_gene.is_cg", cnn_Pegase, adOpenDynamic, adLockBatchOptimistic
        If Not RECSET.EOF Then
            Worksheets("1 - Feuille de Suivi Commercial").Range("N_CG_bulletin_de_souscription_C11").Value = RECSET.fields("s_no_cg").Value
        Else
            Worksheets("1 - Feuille de Suivi Commercial").Range("N_CG_bulletin_de_souscription_C11").Value = ""
        End If
    RECSET.Close
End Sub

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章