Quotes within quotes + wildcard characters

M

Melissa

I don't know if I will ever wrap my head around using quotes within quotes!
If someone could help, that would be great!

I'm trying to filter a form after updating an unbound text box. I don't
think my strfilter variable is correct because when I use the ApplyFilter
method I get a message box prompting me to input Me.Description. I know I
spelled it correctly and that it is a valid field on my form. Here's my code
strFilter = "Me.Description Like ""*" & Me.DescriptionFilter & "*"""
DoCmd.ApplyFilter , strFilter
 
J

John Spencer

Try something like the following.

strFilter = "[Description] Like ""*" & Me.DescriptionFilter & "*"""


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
M

Melissa

That worked like a charm, but why? Why wouldn't me.Description work? Is it
because it was in the footer of the form? Would love to know the answer so I
can learn :) Thanks so much again. I couldn't manage without this site :)
--
Thanks.


John Spencer said:
Try something like the following.

strFilter = "[Description] Like ""*" & Me.DescriptionFilter & "*"""


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

I don't know if I will ever wrap my head around using quotes within quotes!
If someone could help, that would be great!

I'm trying to filter a form after updating an unbound text box. I don't
think my strfilter variable is correct because when I use the ApplyFilter
method I get a message box prompting me to input Me.Description. I know I
spelled it correctly and that it is a valid field on my form. Here's my code
strFilter = "Me.Description Like ""*" & Me.DescriptionFilter & "*"""
DoCmd.ApplyFilter , strFilter
 
J

John Spencer

You are filtering the records to be displayed using the DESCRIPTION FIELD in
the query (or table). Me.Description is referring to the control on the form.
The form's record source (query or table) has no idea what ME refers to and
Me.Description is definitely not a field. The query would attempt to
interpret ME as the name of a table or query and Description as a field in the
table named Me.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top