Hi everybody...
I have a query that does'nt work, maybe I have an error into it or it's not possible what I'm trying to do ??? Refer to the underlined and bold line in the code below...
I want that the strSQL query will be equal to the PrimaryKey of the value in the Combobox
Here is the code (Sorry some words are in french):
Thanks in advance !VB Code:
'Instanciation des variables Set cn = New ADODB.Connection Set rs = New ADODB.Recordset Set cmdSQL = New ADODB.Command Set prmSQL = New ADODB.Parameter 'Connection Database cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & adoSource cn.Open 'Création de la requête strSQL = "SELECT Desc_F FROM RevType WHERE TypePK in (SELECT TypePK FROM Revetement WHERE CategPK = ?)" 'Configurer la commande cmdSQL.CommandText = strSQL cmdSQL.CommandType = adCmdText 'Création du paramètre Set prmSQL = cmdSQL.CreateParameter("Whatever", adVarChar, adParamInput, 255, [B][U]"SELECT CategPK FROM RevCategorie WHERE Desc_F = " & cboFexRev(0).Text[/U][/B]) cmdSQL.Parameters.Append prmSQL 'Exécuter la requête paramétrée Set cmdSQL.ActiveConnection = cn Set rs = cmdSQL.Execute 'Vider le ComboBox adoCombo.Clear 'Positionner sur le premier recordset rs.MoveFirst 'Ajouter Items ComboBox Do Until rs.EOF adoCombo.AddItem rs.Fields("Desc_F").Value 'Déplace curseur sur prochain recordset rs.MoveNext Loop 'Fermeture de la connection ADO rs.Close Set rs = Nothing cn.Close Set cn = Nothing





Reply With Quote