对Access进行数据查找时如何能区分大小写?

JayZhou 2003-08-26 09:56:39
请明示!
...全文
217 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqfleaf 2003-08-26
  • 打赏
  • 举报
回复
http://support.microsoft.com/default.aspx?scid=kb;en-us;209674
viena 2003-08-26
  • 打赏
  • 举报
回复
对每一个字符,if >=Asc("a") And <=Asc("z") ,then 小写
if >=Asc("A") And <=Asc("Z") ,then 大写
icansaymyabc 2003-08-26
  • 打赏
  • 举报
回复
ACC2000: How to Return Case-Sensitive Matches in Queries
The information in this article applies to:
Microsoft Access 2000

This article was previously published under Q209674
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).


SUMMARY
You can use the Asc() function or the StrComp() function to have Microsoft Access differentiate between case-sensitive text strings. When you use the Asc() function in a select query, Access can locate an exact, case-sensitive match using the first letter of a text string. The StrComp() function can perform a case-sensitive match for the whole string.

Both of these functions can be useful in checking for names in a database that are supposed to be uppercase or proper case, but which have been entered incorrectly.
MORE INFORMATION
To find all the records in a field that contain lowercase text rather than uppercase text for the first character, use either of the following methods.
Method 1: Find Text With an Initial Lowercase Letter Using the Asc() Function
Start Microsoft Access, and then create a new blank database.
Create a new table with the following field:
Field Name: FirstName
Data Type: Text
Field Size: 50

Field Name: LastName
Data Type: Text
Field Size: 50

Save the table as tblNameList. When you are prompted to create a key field, click No.
Add the following records to the tblNameList table: FirstName LastName
--------- ----------
Andrew Maclean
Nancy Macleod
Zareda van Helsing
andrew MacLean
nancy MacLeod
zareda Van Helsing

Create a new query based on the tblNameList table, and then enter the following data in the query grid:
Field: FirstName
Table: tblNameList
Show: True

Field: LastName
Table: tblNameList
Show: True

Field: Asc([FirstName])
Show: False
Criteria: >=Asc("a") And <=Asc("z")

Run the query. Note that you have selected only the records that contain first names with an initial lowercase letter.
Method 2: Find Text With a Lowercase Letter in Any Position Using the StrComp() Function
If you have not already done so, create the test database using steps 1 through 3 in Method 1.
Create a new query based on the tblNameList table, and then enter the following data in the query grid:
Field: StrComp([FirstName],"a",0)
Show: False
Criteria: 1

Field: FirstName
Table: tblNameList
Show: True

Field: LastName
Table: tblNameList
Show: True


Run the query. Note that the query returns the same results as in Method 1.
Open the query in Design View, and then change the Field parameters in the first column of the query grid to:
Field: StrComp([LastName],"Mack",0)

Run the query. Note that the query returns "Maclean" and "Macleod," but not "MacLean" and "MacLeod." The records for "van Helsing" are also selected because the criteria you entered for the StrComp() function returns any binary values that are greater than the search criteria "Mack."
REFERENCES
For more information about the Asc() function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type asc function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about the StrComp() function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type strcomp function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Last Reviewed: 3/10/2003
Keywords: kbhowto kbinfo kbusage KB209674
JayZhou 2003-08-26
  • 打赏
  • 举报
回复
对不起,我这里不能出国,那个到底是什么?

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧