cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA - Escape char on select query

mrajih
Super Contributor

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

mrajih
Super Contributor

Thank you for your help, it works

asantillo
MEGA
MEGA

Hello,

 

you try this:

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

...

End If

 

Regards

mrajih
Super Contributor

Hello,

 

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

 

Thank you