使用“like”进行简单查询不工作> :( [英] Simple query with "like" not working >:(

查看:66
本文介绍了使用“like”进行简单查询不工作> :(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我很困惑......


我正在两个表之间的访问97中进行查询。

中有一个字段叫做DWGNO。


OPENORD有一条DWGNO为00000012345的记录

DIEDATA有一个DWGNO为12345的记录


我现在不用VBA做这个。我正在通过查询这样做

gui。


我的查询:

两个表都在上面的部分他们之间没有联系。

我选择了4个字段。只有3个被告知显示结果。

未显示结果的字段是输入条件的位置。

该字段名为DieData.DWGNO,标准为Like " * QUOT; &

[openord]![dwgno]


这显示没有查询结果。

请帮帮我

Ok, I''m baffled...

I''m making a query in access 97 between 2 tables. There is a field in
both tables called "DWGNO".

OPENORD has a record with a DWGNO of "00000012345"
DIEDATA has a record with a DWGNO of "12345"

I''m not doing this with VBA right now. I''m doing it through the query
gui.

My query:
Both tables are in the upper section with no links between them.
I have selected 4 fields. Only 3 are told to display results.
The field that is not showing results is where the criteria is entered.
The field is called DieData.DWGNO and the criteria is Like "*" &
[openord]![dwgno]

This shows no query results.
Please help me

推荐答案

如果在设计视图中打开这些表,

字段的数据类型是什么?如果它们是文本,则文本不匹配,因为字符串

" 00000012345"不像字符串12345


如果它们是数字类型字段,请注意Like是一个字符串运算符,所以

你还在表演字符串匹配。打开立即窗口(Ctrl + G)

并输入以下行:

? " 12345"像*一样&安培; 00000012345

? " 00000012345"像*一样&安培; 12345

第一个返回False,而第二个返回True。

您给出的示例与第一个不匹配。


另一方面要记住,Nulls与Like*不匹配。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Bruce Lawrence" < BL ***** @ gmail.comwrote in message

news:11 ********************* @ 74g2000cwt.googlegrou ps.com ...
If you open these tables in design view, what is the Data Type of the
fields? If they are Text, the text does not match because the string
"00000012345" is nothing like the string "12345"

If they are Number type fields, be aware that Like is a string operator, so
you are still performing a string match. Open the Immediate Window (Ctrl+G)
and enter these lines:
? "12345" Like "*" & "00000012345"
? "00000012345" Like "*" & "12345"
The first returns False, while the second returns True.
The example you gave is like the first one, which does not match.

The other think to keep in mind is that Nulls don''t match with Like "*".

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bruce Lawrence" <BL*****@gmail.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...

好​​的,我很困惑......


我正在制作一个在两个表之间的访问97中查询。

中有一个字段叫做DWGNO。


OPENORD有一条DWGNO为00000012345的记录

DIEDATA有一个DWGNO为12345的记录


我现在不用VBA做这个。我正在通过查询这样做

gui。


我的查询:

两个表都在上面的部分他们之间没有联系。

我选择了4个字段。只有3个被告知显示结果。

未显示结果的字段是输入条件的位置。

该字段名为DieData.DWGNO,标准为Like " * QUOT; &

[openord]![dwgno]


这显示没有查询结果。

请帮帮我
Ok, I''m baffled...

I''m making a query in access 97 between 2 tables. There is a field in
both tables called "DWGNO".

OPENORD has a record with a DWGNO of "00000012345"
DIEDATA has a record with a DWGNO of "12345"

I''m not doing this with VBA right now. I''m doing it through the query
gui.

My query:
Both tables are in the upper section with no links between them.
I have selected 4 fields. Only 3 are told to display results.
The field that is not showing results is where the criteria is entered.
The field is called DieData.DWGNO and the criteria is Like "*" &
[openord]![dwgno]

This shows no query results.
Please help me



我明白了。


那么,我想我需要一个VBA模块将其转换为常规

数字或删除前导零。


除非你有一些快速复制/粘贴代码,否则我会开始寻找

表示决议。


感谢Allen

I see.

Well, then I guess I need a VBA module to convert this to a regular
number or remove the leading zeros.

Unless you have some quick code to copy/paste here, I''ll start hunting
for a resolution.

Thanks Allen


制作mdb文件的备份副本(同时它没有被使用。)


打开关系窗口(工具菜单),并删除使用这些字段的任何关系




在设计视图中打开表,并将数据类型更改为数字。保存。

验证数字是否仍然正确(没有前导数字。)


关闭表格。再次返回Relationships窗口,并与选中的Referential Integrity框创建

关系。


它们现在应该正确匹配。


BTW,如果你愿意,你仍然可以用前导零显示它们,即使在

将它们转换为数字后也是如此。只需将字段的Format属性设置为:

00000000000

-

Allen Browne - Microsoft MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Bruce Lawrence" < BL ***** @ gmail.comwrote in message

news:11 ********************** @ h48g2000cwc。 googlegr oups.com ...
Make a backup copy of the mdb file (while it is NOT in use.)

Open the Relationships window (Tools menu), and remove any relationships
that use these fields.

Open the tables in design view, and change the Data Type to Number. Save.
Verify the numbers are still correct (sans the leading digits.)

Close the tables. Go back to the Relationships window again, and create the
relations with the Referential Integrity box checked.

They should now match correctly.

BTW, you can still display them with leading zeros if you wish, even after
converting them to numbers. Just set the Format property of the fields, to:
00000000000

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bruce Lawrence" <BL*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...

>我明白了。


嗯,那我想我需要一个VBA模块将此转换为常规

数字或删除前导零。


除非你有一些快速代码要复制/粘贴,否则我会开始狩猎

的分辨率。


谢谢Allen
>I see.

Well, then I guess I need a VBA module to convert this to a regular
number or remove the leading zeros.

Unless you have some quick code to copy/paste here, I''ll start hunting
for a resolution.

Thanks Allen



这篇关于使用“like”进行简单查询不工作&gt; :(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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