Unbound Search是否是最佳解决方案? [英] Is Unbound Search Form the best solution?

查看:79
本文介绍了Unbound Search是否是最佳解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Access有点新,并且根本没有VB经验(除了修改现有代码之外)。


我构建了一个工作正常的数据输入表单。通常,客户端将调用并且用户必须找到他的记录以添加或修改现有数据。最初,我基于具有姓氏和名字的输入条件的查询构建了表单。 Last_Name标题是[什么是姓氏?]&" *"部分名称将起作用。该查询还包括一个类似的名字标准。


然后,我需要通过Client_ID启用搜索。我为此构建了一个新查询,因为我不希望用户必须查看Name的弹出对话框。这种方法的问题是我不得不根据第二个查询而不是第一个查询来复制现有的数据输入表单。我不想保留两个相同的表格。


我决定尝试使用这三个字段的未绑定搜索表单,以便我可以使用单个查询和表单。它几乎可以工作。直接调用时查询工作正常,但是当我使用搜索表单根据查询调用数据输入表单时,它会出错。


我的查询符合以下条件: br />

Client_ID:[表格]![search_Form]![S_ID]


然后,在单独的标准行(意味着OR)


Last_Name:喜欢IIf(IsNull([forms]![Search_Form]![S_Last]),Null,[Forms]![Search_Form]![S_Last]&" *")


AND


First_Name:喜欢([Forms]![Search_Form]![S_First]&" *")


我的想法是,如果搜索表单中的姓氏留空(Null),它将根据NAME行返回任何内容。我直接查询时工作正常。如果我输入名称数据,它只返回适当的名称记录,如果我输入Client_ID,它只返回该Client_ID。但是,如果我使用Search_Form,则只有NAME条件有效。如果我输入一个Client_ID,它将返回所有名称而不是所有名称。


我的搜索表单只包含这三个字段,并且它们是未绑定的。我尝试使用和不指定字段参数的查询(名称字段=文本,Client_ID字段=长整数),它没有任何区别。


任何人都可以帮忙吗?

I''m somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious).

I built a data entry form that works fine. Typically, a client will call in and the user has to find his record to add or modify existing data. Originally, I built the form based on a query with an input criteria for the last name and first name. The Last_Name critera is Like [What is Last Name?]&"*" so that partial names will work. The query also includes a similar criteria for first name.

Then, I needed to enable the search by Client_ID. I built a new query for this, because I didn''t want the user to have to see the pop-up dialogs for Name. The problem with this approach is that I had to duplicate the existing data entry form based on the second query instead of the first. I don''t want to have to maintain two identical forms.

I decided to try an unbound search form with these three fields, so that I could use a single query and form. It almost works. The query works fine when called directly, but when I use the search form to call the data entry form based upon the query, it goes awry.

My query has the following criteria:

Client_ID: [Forms]![search_Form]![S_ID]

Then, on a separate criteria line (meaning OR)

Last_Name: Like IIf(IsNull([forms]![Search_Form]![S_Last]),Null,[Forms]![Search_Form]![S_Last] & "*")

AND

First_Name: Like ([Forms]![Search_Form]![S_First] & "*")

My thinking was that if the last name from the Search form is left blank (Null), it will return nothing based on the NAME line. It works fine when I query directly. If I input name data, it only returns appropriate names records, and if I input a Client_ID, it only returns that Client_ID. However, if I use the Search_Form, only the NAME criteria works. If I input a Client_ID, it returns all names instead of none.

My search form consists only of these three fields and they are unbound. I tried the query with and without the field parameters specified (name fields=text, Client_ID field = long integer) and it made no difference.

Can anyone help?

推荐答案

我已经完成了这个并且看不到任何错误。

也许如果你发布你正在使用的查询的SQL这可能会给我们提供更多线索。

BTW这样做,设计查询然后将视图切换到SQL。

复制该窗口的内容并在此处发布[代码]& [/ CODE]标签。
I''ve gone through this and can''t see anything amiss.
Perhaps if you post the SQL of the query you''re using that might give us some more clues.
BTW to do that, design the query then switch views to SQL.
Copy the contents of that window and post in here between [ C O D E] & [ / C O D E] tags.


使用相同类型的 IIF()作为姓氏的第一个名称不是更好?
Wouldn''t it be better to use the same type of IIF( ) for the first name that you used for last name?



第一次使用相同类型的 IIF()并不是更好你用于姓氏的名字?
Wouldn''t it be better to use the same type of IIF( ) for the first name that you used for last name?



我认为没有任何好处,因为第一个名称标准与姓氏标准在同一行,而一个空的姓氏足以返回no来自查询的名称条件的值。

I see no benefit to that, since a the first name criteria is on the same line as the last name criteria, and a null last name is enough to return no values from the name criteria of the query.


这篇关于Unbound Search是否是最佳解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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