Bonjour,
Suite à la création d'un formulaire et de l'utilisation de la fonction SELECT j'ai le message suivant:
Or je ne trouve pas mon erreur. Je vous met donc mon code pour que quelqu'un regarde rapidement et puisse m'aider.Dans l'instruction SELECT, un mot réservé ou un argument est mal orthographié ou absent, ou la ponctuation est incorrecte
Code:Private Sub RefreshQuery() Dim SQL As String Dim SQP As String Dim SQLWhere As String SQL = "SELECT Nom_de_famille, Prenom, Entreprise, Num_Tel, e_Mail, Groupe, Commentaire FROM Contacts WHERE Contacts.num <> 0 " '______________ If Me.cNom Then If Me.chNom = "Tout" Then SQL = SQL & "And (Contacts.Nom_de_famille like '*" & Me.CmdNom & "*' Or Contacts.Prenom like '*" & Me.CmdNom & "*' Or Contacts.Entreprise like '*" & Me.CmdNom & "*') " End If If Me.chNom = "Nom" Then SQL = SQL & "And Contacts.Nom_de_famille like '*" & Me.CmdNom & "*' " End If If Me.chNom = "Prenom" Then SQL = SQL & "And Contacts.Prenom like '*" & Me.CmdNom & "*' " End If If Me.chNom = "Entreprise" Then SQL = SQL & "And Contacts.Entreprise like '*" & Me.CmdNom & "*' " End If ' * inseré avant et après le nom permet de trouver des morceaux de mot End If '______________ If Me.cCategorie Then SQL = SQL & "And Contacts.Groupe = '" & Me.chCategorie & "' " End If '______________ If Me.cTel Then SQL = SQL & "And Contacts.Num_Tel= '" & Me.CmdTel & "' " End If '______________ If Me.cVille Then If Me.chVille = "Ville" Then SQL = SQL & "And Contacts.Ville like '*" & Me.CmdVille & "*' " End If If Me.chVille = "Code postal" Then SQL = SQL & "And Contacts.Code_postal like '*" & Me.CmdVille & "*' " End If End If '______________ If Me.cMail Then SQL = SQL & "And Contacts.e_Mail = '" & Me.CmdMail & "' " End If '______________ ' affichage du nombre de contacts SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1)) ' rangement dans l'ordre croissant If Me.rg = "Nom" Then SQP = "ORDER BY Contacts.Nom_de_famille" Requery End If If Me.rg = "Prenom" Then SQP = "ORDER BY Contacts.Prenom" Requery End If If Me.rg = "Entreprise" Then SQP = "ORDER BY Contacts.Entreprise" Requery End If If Me.rg = "Categorie" Then SQP = "ORDER BY Contacts.Groupe" Requery End If If Me.rg = "Numero de telephone" Then SQP = "ORDER BY Contacts.Num_Tel" Requery End If If Me.rg = "Mail" Then SQP = "ORDER BY Contacts.e_Mail" Requery End If SQL = SQL & SQP & ";" 'affichage liste contacts voulus Me.lblStats.Caption = DCount("*", "Contacts", SQLWhere) & " / " & DCount("*", "Contacts") Me.lstResults.RowSource = SQL Me.lstResults.Requery End Sub
-----