SELECT FROM en utilisant un ComboBox

jpujol95 Messages postés 60 Date d'inscription dimanche 20 octobre 2002 Statut Membre Dernière intervention 5 septembre 2004 - 5 sept. 2004 à 11:09
cs_frop01 Messages postés 1352 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 19 novembre 2008 - 5 sept. 2004 à 13:44
Bonjour depuis ce matin je cherche comment faire ceci:

sql = "SELECT * FROM Employés where Nom= combo1.text"

Je m'embrouille avec toutes ces "" et ' et les chr$(34)!!!

Il faut que même si Nom = "L'ardiette" ca marche aussi !!!

Merci de votre aide!

J.PUJOL95 :)

3 réponses

MDBen_pff Messages postés 35 Date d'inscription dimanche 20 juin 2004 Statut Membre Dernière intervention 13 septembre 2004
5 sept. 2004 à 12:33
Salut, dans un module place ette fonction :
Function Quote(str As String)
   If IsNull(str) Then
      Quote = "''"
   Else
      Quote = "'" & Replace(str, "'", "''") & "'"
   End If
End Function


Puis ensuite tu fais :

sql = "SELECT * FROM Employés where Nom= Quote(combo1.text);"


MdBen-pff
A++ bon code
Et n'oubliez pas le tag Réponse acceptée ! :big)
0
cs_frop01 Messages postés 1352 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 19 novembre 2008 2
5 sept. 2004 à 13:41
Exact ,

Si tu mets la fonction dans un module, il faut la rendre Public
Public Function Quote

et puis pour la requête


sql = "SELECT * FROM Employés where Nom= " & Quote(Text1) & ";"



:-p [mailto:cyberscorp2004@msn.com MSN] :big) [mailto:frop01@yahoo.fr YAHOO] >:)
0
cs_frop01 Messages postés 1352 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 19 novembre 2008 2
5 sept. 2004 à 13:44
Erreur de saisie

Au lieu de :


sql = "SELECT * FROM Employés where Nom= " & Quote(<s>Text1</s>) & ";"



Voila


sql = "SELECT * FROM Employés where Nom= " & Quote(combo1.text) & ";"



:-p [mailto:cyberscorp2004@msn.com MSN] :big) [mailto:frop01@yahoo.fr YAHOO] >:)
0
Rejoignez-nous