Form filter for recordset

  • Thread starter Thread starter Pete Beall
  • Start date Start date
P

Pete Beall

I have a form filtered by variable numbers of multiple criteria
and I want to apply that filter to a recordset. I've tried appending the
filter as the WHERE clause, but I hit the problem of having single quotes in
my SQL:

((Lookup_GrapeID.[Grape/Designation]="Zinfandel") AND
(Lookup_SupplierID.Supplier="DeLaurenti"))

Anyone have some guidance?

Pete Beall
 
I have a form filtered by variable numbers of multiple criteria
and I want to apply that filter to a recordset. I've tried appending the
filter as the WHERE clause, but I hit the problem of having single quotes in
my SQL:

((Lookup_GrapeID.[Grape/Designation]="Zinfandel") AND
(Lookup_SupplierID.Supplier="DeLaurenti"))

Anyone have some guidance?

Pete Beall

Umm... you don't HAVE single quotes in your SQL, at least not in this
example; and even if you did it should still work since you're
delimiting the values with doublequotes, not singlequotes. Could you
post some of the code in context?
 
-----Original Message-----

I have a form filtered by variable numbers of multiple criteria
and I want to apply that filter to a recordset. I've tried appending the
filter as the WHERE clause, but I hit the problem of having single quotes in
my SQL:

((Lookup_GrapeID.[Grape/Designation]="Zinfandel") AND
(Lookup_SupplierID.Supplier="DeLaurenti"))

Anyone have some guidance?

Pete Beall
Hi Pete, your example shows double quotes?...

The rule seems to be use single quotes within double quotes
"((Lookup_GrapeID.[Grape/Designation]='Zinfandel') AND
(Lookup_SupplierID.Supplier='DeLaurenti'))"

or

double quotes within single quotes.
'((Lookup_GrapeID.[Grape/Designation]="Zinfandel") AND
(Lookup_SupplierID.Supplier="DeLaurenti"))'

or

doubleup on double quotes
""((Lookup_GrapeID.[Grape/Designation]="""Zinfandel""") AND
(Lookup_SupplierID.Supplier="""DeLaurenti"""))"

or use chr(34) for embeded quotes
"((Lookup_GrapeID.[Grape/Designation]=" & chr(34)
& "Zinfandel" & chr(34) ") AND
(Lookup_SupplierID.Supplier=" & chr(34) & "DeLaurenti" &
chr(34) & "))"

Take your pick
Luck
Jonathan
 
I don't see any single quotes in what you posted... could you be more
specific?

Larry Linson
Microsoft Access MVP
 
Back
Top