如何在MS-Access的组合框中增加区分大小写的功能? [英] How to add case-sensitivity to a Combo box in MS-Access?

查看:129
本文介绍了如何在MS-Access的组合框中增加区分大小写的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有RowSource的组合框.显示时,它显示来自查询的项目列表.该查询有两列.当用户选择某项内容时,第一列存储在表中,但第二列显示(工作正常).

I have a combo box with a RowSource. When it displays, it shows a list of items that come from a query. The query has two columns. When the user chooses something, the first column is stored in the table, but the second column is displayed (works fine).

当您进入表单并查看一些现有数据时,它会像显示查询一样显示来自查询(RowSource)的显示值.大多数时候效果很好.

When you come to the form and view some existing data, it shows the display value from the query (RowSource) like it should. Works nice most of the time.

挑战在于我的组合框之一处理了区分大小写的键.显示错误的内容.

The challenge is that one of my combo boxes deals with case-sensitive keys. The wrong stuff is getting shown.

以下是一些人为数据:

id   value
[a1] [Apples]
[A1] [Oranges]

下面的表格是这样的:

MyTable
id: int
...other fields...
fruit_key: string

fruit_key列包含"a1"时,我想查看Apple.当它包含"A1"时,我想看到橘子.

When the fruit_key column contains, "a1", I want to see Apples. When it contains "A1", I want to see Oranges.

发生的事情是,我总是看到Apple,因为它在进行不区分大小写的匹配.

What's happening is that I am always seeing Apples because it's doing a case-insensitive match.

如何将其更改为区分大小写?

How do I change this to case-sensitive?

推荐答案

您不能使用,除非使用繁琐的解决方法.来自如何通过Microsoft Jet执行区分大小写的联接:

You can't, except with kludgy workarounds. From How To Perform a Case-Sensitive JOIN Through Microsoft Jet:

Microsoft Jet数据库引擎本质上不区分大小写.

The Microsoft Jet database engine is inherently case-insensitive.

没有办法改变它.

在WHERE条件和查询中的JOIN中,可以使用二进制字符串比较:StrComp(Field1, Field2, 0) = 0.

In WHERE conditions and JOINs in queries, you can work with binary string compare: StrComp(Field1, Field2, 0) = 0.

但是在这里,使用绑定的组合框,最好的选择是将fruit_key字符串转换为例如十六进制字符串(请参见文章中的十六进制扩展).

But here, with the bound combobox, your best choice would be to convert the fruit_key string into e.g. a hex string (see Hexadecimal Expansion in the article).

在组合框的行源中,您可以使用计算列,但在要使用组合框进行编辑的表中,除了fruit_key外,您还必须实际存储十六进制字符串,因为您可以t编辑计算列.

In the rowsource of the combobox you could use a computed column, but in the table you want to edit with the combobox, you'd have to actually store the hex string in addition to the fruit_key, because you can't edit a computed column.

我不确定二进制字段方法是否适用于您的情况.

I'm not sure if or how the Binary Field method would work in your case.

总而言之,您可能会变得更好

All in all you'd probably be better off by

  • 以不同的方式进行操作",这样您就不需要区分大小写的数据,或者
  • 不是将Jet用作后端,而是服务器数据库,您可以在其中设置区分大小写的排序规则.

这篇关于如何在MS-Access的组合框中增加区分大小写的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆