ADODB query

%3CLINGO-SUB%20id%3D%22lingo-sub-2060114%22%20slang%3D%22en-US%22%3EHow%20can%20I%20declare%20the%20variable%20from%20the%20list%20in%20ADODB%20query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2060114%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI%20have%20a%20liste%20of%20choices%3A%20I%20would%20like%20to%20click%20on%20this%20list%20and%20use%20the%20variable%20in%20my%20ADODB%20query%3A%20I%20don't%20know%20how%20to%20declare%20the%20chosen%20variable%20from%20list%20(LFG%20-CORTAGE%20-%20999)%20in%20the%20query.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20joined%20the%20image%20of%20the%20list.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EMy%20code%20is%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EPublic%20Sub%20N_CG_bulletin_de_souscription(%3CSPAN%3ELFG%20-CORTAGE%20-%20999%20%3F%3C%2FSPAN%3E%20As%20String)%3C%2FP%3E%3CP%3EDim%20RECSET%20As%20New%20ADODB.Recordset%3CBR%20%2F%3ERECSET.Open%20%22select%20cond_gene.s_no_cg%20from%20db_dossier%20sousc%2C%20db_protocole%20proto%2C%20db_tiers%20tiers%2C%20db_cond_gene%20cond_gene%2C%20dr_protocole_cg%20protocole_cg%2C%20db_personne%20pers%2C%20db_contrat%20cont%20%22%20%26amp%3B%20_%3CBR%20%2F%3E%22%20where%20sousc.no_police%20%3D%20'%22%20%26amp%3B%20%3CSPAN%3ELFG%20-CORTAGE%20-%20999%20%3F%3C%2FSPAN%3E%20%26amp%3B%20%22'%20and%20sousc.cd_dossier%20%3D%20'SOUSC'%20and%20sousc.lp_etat_doss%20not%20in%20('ANNUL'%2C'A30'%2C'IMPAY')%20and%20sousc.is_dossier%20%3D%20cont.is_dossier%20and%20cont.is_cg%20%3D%20cond_gene.is_cg%22%2C%20cnn_Pegase%2C%20adOpenDynamic%2C%20adLockBatchOptimistic%3CBR%20%2F%3EIf%20Not%20RECSET.EOF%20Then%3CBR%20%2F%3EWorksheets(%221%20-%20Feuille%20de%20Suivi%20Commercial%22).Range(%22N_CG_bulletin_de_souscription_C11%22).Value%20%3D%20RECSET.Fields(%22s_no_cg%22).Value%3CBR%20%2F%3EElse%3CBR%20%2F%3EWorksheets(%221%20-%20Feuille%20de%20Suivi%20Commercial%22).Range(%22N_CG_bulletin_de_souscription_C11%22).Value%20%3D%20%22%22%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3ERECSET.Close%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20help%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2060114%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2060187%22%20slang%3D%22en-US%22%3ERe%3A%20How%20can%20I%20declare%20the%20variable%20from%20the%20list%20in%20ADODB%20query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2060187%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F928824%22%20target%3D%22_blank%22%3E%40Masha_Paris%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20LFG%20-CORTAGE%20-%20999%20as%20a%20column%20header%20in%20an%20Excel%20table%2C%20but%20it%20is%20not%20valid%20as%20a%20variable%20name.%20Spaces%20and%20hyphens%20aren't%20allowed.%20Use%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPublic%20Sub%20N_CG_bulletin_de_souscription(CORTAGE%20As%20String)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20...%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%20where%20sousc.no_police%20%3D%20'%22%20%26amp%3B%20CORTAGE%20%26amp%3B%20%22'%20and%20sousc.cd_dossier%20%3D%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20...%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20call%20the%20procedure%2C%20pass%20the%20value%20of%20a%20cell%20in%20the%20LFG%20-CORTAGE%20-%20999%20column%20to%20the%20CORTAGE%20argument.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Deleted
Not applicable

test

 

1 Reply

@Deleted 

You can use LFG -CORTAGE - 999 as a column header in an Excel table, but it is not valid as a variable name. Spaces and hyphens aren't allowed. Use something like this:

 

Public Sub N_CG_bulletin_de_souscription(CORTAGE As String)
    ...
    " where sousc.no_police = '" & CORTAGE & "' and sousc.cd_dossier = 
    ...

 

When you call the procedure, pass the value of a cell in the LFG -CORTAGE - 999 column to the CORTAGE argument.