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):
VB Code:
  1. 'Instanciation des variables
  2. Set cn = New ADODB.Connection
  3. Set rs = New ADODB.Recordset
  4. Set cmdSQL = New ADODB.Command
  5. Set prmSQL = New ADODB.Parameter
  6.  
  7. 'Connection Database
  8. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & adoSource
  9. cn.Open
  10.  
  11. 'Création de la requête
  12. strSQL = "SELECT Desc_F FROM RevType WHERE TypePK in (SELECT TypePK FROM Revetement WHERE CategPK = ?)"
  13.  
  14. 'Configurer la commande
  15. cmdSQL.CommandText = strSQL
  16. cmdSQL.CommandType = adCmdText
  17.  
  18. 'Création du paramètre
  19. Set prmSQL = cmdSQL.CreateParameter("Whatever", adVarChar, adParamInput, 255, [B][U]"SELECT CategPK FROM RevCategorie WHERE Desc_F = " & cboFexRev(0).Text[/U][/B])
  20. cmdSQL.Parameters.Append prmSQL
  21.  
  22. 'Exécuter la requête paramétrée
  23. Set cmdSQL.ActiveConnection = cn
  24. Set rs = cmdSQL.Execute
  25.  
  26. 'Vider le ComboBox
  27. adoCombo.Clear
  28.  
  29. 'Positionner sur le premier recordset
  30. rs.MoveFirst
  31.         'Ajouter Items ComboBox
  32.         Do Until rs.EOF
  33.                 adoCombo.AddItem rs.Fields("Desc_F").Value
  34.                 'Déplace curseur sur prochain recordset
  35.                 rs.MoveNext
  36.         Loop
  37.  
  38. 'Fermeture de la connection ADO
  39. rs.Close
  40. Set rs = Nothing
  41. cn.Close
  42. Set cn = Nothing
Thanks in advance !