Filter form with 2 combo boxes error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

I have a little problem filtering two fields in a continuous form :(


Private Sub filtro_Click()
Dim ftrcand As String
Dim ftrseccao As String

ftrcand = "[desig_candidatura_a] = '" & Me!cand_a & "'"
ftrseccao = "[gt design] = '" & Me!gt & "'"

If ((Not IsNull(Me.cand_a)) And (((Not IsNull(Me.gt)) ))) Then
Me.Filter = "[desig_candidatura_a] = '" & Me!cand_a & "'" and "[gt design] =
'" & Me!gt & "'"
Me.FilterOn = True
End If

Both fields are in text format, and if i try to filter only one option there
is no problem

--
Thanks,

Sorry if my english isn''t correct, but I''m from Potugal ;)

Emanuel Violante Galeano
 
Emanuel Violante said:
Hi everyone,

I have a little problem filtering two fields in a continuous form :(


Private Sub filtro_Click()
Dim ftrcand As String
Dim ftrseccao As String

ftrcand = "[desig_candidatura_a] = '" & Me!cand_a & "'"
ftrseccao = "[gt design] = '" & Me!gt & "'"

If ((Not IsNull(Me.cand_a)) And (((Not IsNull(Me.gt)) ))) Then
Me.Filter = "[desig_candidatura_a] = '" & Me!cand_a & "'" and "[gt design]
=
'" & Me!gt & "'"
Me.FilterOn = True
End If

Both fields are in text format, and if i try to filter only one option
there
is no problem


The quotes are not quite right, the "and" is falling outside the quotes,
causing it to be interpreted as part of the VBA code instead of as part of
the SQL statement. Try something like this ...

Me.Filter = "[desig_candidatura_a] = '" & Me!cand_a & "' And [gt design] =
'" & Me!gt & "'"
 
Back
Top