Solved Filter with a sql string

Etxezarreta

Member
Local time
Today, 07:34
Joined
Apr 13, 2020
Messages
175
Hello everyone,
I would like to filter a form with the following string: the parameter is at the right format (string), I ran a few tests with constants, and it works:
May some help me please?
Many thanks in advance!

Code:
str_pub_dpt = "SELECT DISTINCT t_CrRdv.Departement" _
            & " FROM (t_ListeDSP INNER JOIN t_DspDepartement ON t_ListeDSP.ID_DSP = t_DspDepartement.Fk_Dsp) INNER JOIN t_CrRdv ON (t_ListeDSP.ID_DSP = t_CrRdv.FK_DSP) AND (t_DspDepartement.Departement = t_CrRdv.Departement)" _
            & " WHERE (((t_ListeDSP.ID_DSP)=[Formulaires]![f_CrRdv]![txt_CritereDsp]))"

Me.Filter = "Departement In ('" & str_pub_dpt & "')"

Me.FilterOn = True
 
Try using InStr().
 
Thank you: an error message pops-up:
1629901457923.png
 
remove the single Quote since the expression is a Query:

Me.Filter = "Departement In (" & str_pub_dpt & ")"
 

Users who are viewing this thread

Back
Top Bottom