cancel
Showing results for 
Search instead for 
Did you mean: 

VBA - Escape char on select query

SOLVED
Occasional Contributor

VBA - Escape char on select query

Helllo,

I'm trying to use a variable on a select query, but one of the application name has a simple cote on the name, I then get an error message. The code works fine on other applications.

 

The application name on error : (COURS : Accèder aux documents d'un cours)

The code I use : 

################################################################

For Each oApp In myRoot.GetCollection("Application")
   sApp = oApp.GetProp("Nom court")

   If myRoot.GetSelection("Select [Application] Where [Nom court] = '" & sApp & "'" & "", "Nom court").Count > "1" Then          <=== line with error
      Worksheets("Objet_en_doublon").Cells(i, 1).Value = "Application"
      Worksheets("Objet_en_doublon").Cells(i, 2).Value = oApp.GetProp("Nom court")
      Worksheets("Objet_en_doublon").Cells(i, 3).Value = oApp.GetProp("Nom")
      Worksheets("Objet_en_doublon").Cells(i, 4).Value = oApp.GetProp("_HexaIdAbs")

      i = i + 1
   End If
Next

#################################################################################

 

Thank you for your help

Mehdi

 

 

3 REPLIES
Occasional Contributor

Re: VBA - Escape char on select query

Hello,

 

If you have any other technique to check for duplicate objects on Mega repository please share it.

 

Thank you

Re: VBA - Escape char on select query

Hello,

 

you try this:

 If GetRoot.GetSelection("Select [Application] Where [Nom court] = """ & sApp & """").Count > 1 Then

...

End If

 

Regards

Occasional Contributor

Re: VBA - Escape char on select query

Thank you for your help, it works