Trouble with rs.Filter not recognizing wildcards (*)

  • Thread starter anthony.pierdominici
  • Start date
A

anthony.pierdominici

I have been searching for the answer to this and can't seem to find
it.

I am trying to apply a filter to a recordset in VBA and it works
perfectly except for when one of the conditions is a wildcard.

Example:
frmFilter has a number of combo boxes from which the user can specify
criteria that will be used in the filter. So say cboName = "*" and my
filter string is is something like this:

[Name] Like '*'

This returns no records...

I have also tried to make the string like this:

[Name] Like "*"

But that doesn't work either.

The first example (using Like with single quotes) seems to work for
everything except when the only thing in the combo box is the
asterisk. If I put any character and an asterisk (ex. D*) in the
combo box it will return records.

Anyone have any ideas on how to fix this?

Thanks,

Anthony Pierdominici
 
A

anthony.pierdominici

I figured this out on my own and thought that someone else might want
to know the answer...

The problem was that VBA doesn't like when you put a wildcard first,
it needs to be a character. So I dynamically created the string to
either include a filter (if there is something besides an * in the
combo box), and not include it if there is only a * in the combo box.
 
A

anthony.pierdominici

I figured this out on my own and thought that someone else might want
to know the answer...

The problem was that VBA doesn't like when you put a wildcard first,
it needs to be a character. So I dynamically created the string to
either include a filter (if there is something besides an * in the
combo box), and not include it if there is only a * in the combo box.
 

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