0

Using Microsoft Access I want to set a filter for records which include spaces. I tried double escaping by using '""' to no avail.

I have a table like so:

ID    Title
1     Green
2     Blue Yacht 
3     Yellow

and a form just displaying these records. When I now set the filter:

Form.Filter = "TestTable.Title LIKE '*Yellow*'"

it works like a charm. But when trying to filter for "Blue Yacht"

Form.Filter = "TestTable.Title LIKE '*Blue Yacht*'"

I get an empty result. Filtering for just Blue works like it is supposed to. Somehow Access doesn't like the spaces in the filter. How can I filter for e.g. "Blue " or "Blue Yacht"?

4

2 回答 2

1

这是非常奇怪的行为,它应该可以正常工作,您可以尝试使用 Chr 代码而不是空格:

Form.Filter = "TestTable.Title LIKE '*Blue" & Chr(32) & "Yacht*'"
于 2012-08-16T11:29:56.370 回答
1

我在寻找相同问题的解决方案时偶然发现了这个旧线程。到目前为止我没有找到。我想知道这是否是 Access 上的错误或什么。

所以,这是我的情况,我尝试了下面的两个过滤器。我正在过滤和填充数据表子表单。过滤器位于组合框中:柠檬酸盐、Paxgene、Herapin 钠。

Dim sTType as string ... ... 1. sTType = "[Tube Type] LIKE '" & Me.txtTubeType & "*'" 2. sTType = "[Tube Type] ='" & Me.txtTubeType & "' " ... me.Filter = sTType

When Sodium Herapin is selected and applied as filter , the filter comes up with nothing, while I've no problem with the other word filters.

Sol.:我将这段代码向上插入

me.txtTubeType = iif(InStr(Trim(Me.txtTubeType), "Sod") > 0, "Sodium*", me.txtTubeType)

  ...
  ...
  sTType = "[Tube Type] LIKE '" & Me.txtTubeType & "'"
  me.Filter =  sTType

解决方法有点粗糙,但它适用于我的情况。

干杯!

于 2017-11-20T22:47:46.070 回答