英文:
Is there a way to include null values along with selected values in query
问题
当筛选多个类别时,我试图向当前的连接字符串添加一个新的筛选器,以更新已选择的内容,同时也包括空值到 SQL 语句中。我尝试过 (query += query & color = selected OR query & color Is Null,但最终只获取非空值。
这是我尝试过的一个示例:
If Nz(colorFilter, "-") <> "All" Then
query = query & " AND Color Is Null OR Color=" & Chr(34) & Me.colorFilter & Chr(34) & query
End If
请注意,代码中的 """ 和 "&" 是 HTML 实体,用于表示双引号和与号,需要根据实际情况进行替换。
英文:
When filtering multiple categories, I am attempting to add a new filter to a current concatenated string that updates what has been selected, but also includes null values to an sql statement. I have tried (query += query & color = selected OR query & color Is Null, but it ends up only grabbing the non null values.
Here is an example of something I've tried
If Nz(colorFilter, "-") <> "All" Then
query = query & " AND Color Is Null OR Color=" & Chr(34) & Me.colorFilter & Chr(34) & query
End If
答案1
得分: 1
query = query & " AND (Color Is Null OR Color = " & Chr(34) & Me.colorFilter & Chr(34) & ")"
英文:
Try this:
query = query & " AND (Color Is Null OR Color = " & Chr(34) & Me.colorFilter & Chr(34) & ")"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论