首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在ADODB查询中声明列表中的变量?

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

Stack Overflow用户
提问于 2021-01-14 18:10:01
回答 1查看 82关注 0票数 0

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

我的列表:.com/cfm5G.png

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-14 20:18:42

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

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65716988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档