DLookup来自查询条件的麻烦 [英] DLookup from a query criteria trouble

查看:83
本文介绍了DLookup来自查询条件的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[我是新来的]



访问03


我目前遇到问题尝试引用查询时的Dlookup(条件语法)


目前我有1个表,它是L_Emps(包含Employee_ID作为我的键(数字),First_Name和Last_Name(作为文本) )。


我的查询是Query1,它是以下内容:

[I''m new here]


Access 03

I''m currently having an issue using Dlookup when trying to reference a query (criteria syntax)

Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key (numeric), First_Name, and Last_Name (as text).

My query is Query1 which is the following:

展开 | 选择 | 换行 | 行号

推荐答案

嗨DH22,欢迎来到Bytes!


机智没有错你的Dlookup的语法。我确定问题是你正在尝试查询查询中的字段值,在这种情况下是Query1,它有一个参数要求用户输入数据([ID:])。这不仅在这种情况下是不必要的,它将导致Dlookup失败,因为在DLookup中JET数据库引擎将无法将该参数解释为有效字段。


删除来自Query1的参数(整个WHERE子句),看看你是如何继续的。


-Stewart
Hi DH22, and Welcome to Bytes!

There is nothing wrong with your syntax for the Dlookup. I am sure the problem is that you are trying to lookup a field value in a query, Query1 in this case, which has a parameter asking for data entry from the user ([ID:]). Not only is this unnecessary in the circumstances, it will cause a Dlookup failure, because within DLookup the JET database engine will not be able to interpret the parameter as a valid field.

Remove the parameter (the whole WHERE clause) from Query1 and see how you get on.

-Stewart



您好DH22,欢迎来到Bytes!


您的Dlookup语法没有任何问题。我确定问题是你正在尝试查询查询中的字段值,在这种情况下是Query1,它有一个参数要求用户输入数据([ID:])。这不仅在这种情况下是不必要的,它将导致Dlookup失败,因为在DLookup中JET数据库引擎将无法将该参数解释为有效字段。


删除来自Query1的参数(整个WHERE子句),看看你是如何上场的。


-Stewart
Hi DH22, and Welcome to Bytes!

There is nothing wrong with your syntax for the Dlookup. I am sure the problem is that you are trying to lookup a field value in a query, Query1 in this case, which has a parameter asking for data entry from the user ([ID:]). Not only is this unnecessary in the circumstances, it will cause a Dlookup failure, because within DLookup the JET database engine will not be able to interpret the parameter as a valid field.

Remove the parameter (the whole WHERE clause) from Query1 and see how you get on.

-Stewart



嘿,这样做了工作,斯图尔特。谢谢!我的标准仍然非常模糊,但我正在练习。


但是,我需要查询的原因是我将设置一个Dlookup用于与删除功能相结合。


我正在考虑用这句话来表达的最佳方式..


我有一个数据库记录指向文件。字段1指向目录,字段2指向子目录,字段3指向文件,字段4指向帐号,6是后缀。


我需要用户能够输入帐号和后缀,拉出匹配的记录(索引),找到他们想要删除的记录后,可以按下按钮并删除文件。


如果我不能使用表格来调用任何查询告诉它带来的信息,我该怎么设置呢?


我有


Hey, that did work, Stewart. Thank you! I''m still very fuzzy on the criteria, but I''m practicing.

However, the reason why I need the query is I will be setting up a Dlookup to use in conjunction with a delete function.

I''m trying to think of the best way to phrase this..

I have a database with records that point to files. Field 1 points to the directory, field 2 points to the sub directory, field 3 points to the file, field 4 points to the account number and 6 is the suffix.

I need the users to be able to input an account number and the suffix, pull up the matching records (indexes), and upon finding the one they wish to delete be able to press the button and have the file be deleted.

How do I set that up then if I can''t use the form to call whatever the query tells it to bring foward?

I have the

展开 | 选择 | Wrap | 林e数字


您好DH22。我不会为你提到的目的使用Dlookup;我将使用未绑定的组合框(未绑定的控件是未绑定到表或查询中的基础字段的控件)。组合的行源将是基于您提到的表的查询。您可以在查询中使用计算字段将您提到的单独字段值组合到一个文件路径中,您可以将其传递给删除代码。


从选择之后运行删除组合使用组合的After Update事件来根据组合的值运行删除文件代码。


未绑定形式的组合框使得非常灵活的查找控件,作为多个他们可以显示的列都可以在VBA代码中访问,以满足您的任何需要。在这种情况下,您只需要列出文件路径,因此一列就足够了。


-Stewart
Hi DH22. I wouldn''t use Dlookup for the purpose you mention; I''d use an unbound combo box instead (an unbound control is one that is not bound to an underlying field in a table or query). The rowsource of the combo would be a query based on the table you mention. You can use a calculated field in the query to combine the separate field values you mention into a single filepath you can pass to the delete code.

To run the delete after making a selection from the combo use the After Update event of the combo to run the delete file code based on the value of the combo.

Combo boxes in unbound form make very flexible lookup controls, as the multiple columns they can display can all be accessed in VBA code for whatever purposes you might need. In this case, you only need to list the filepaths, so one column should suffice.

-Stewart


这篇关于DLookup来自查询条件的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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