文本框搜索问题。如果找到匹配,则显示表格。如果没有,请添加新内容。 [英] Issue with text box search. If match found, display form. If not, add new.

查看:72
本文介绍了文本框搜索问题。如果找到匹配,则显示表格。如果没有,请添加新内容。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我无法使用Access VBA代码。我正在使用Access 2010(来自工作)/ 2013(来自家庭)。我正在创建一个数据库,分析我工作地点(当地食品银行)预先包装食品的营养质量。


用户输入产品UPC代码(我用作主键)。我想要做的是,如果先前已输入产品,则会打开产品表格。如果它还没有出现在数据库中,我希望它能够使用UPC代码进入一个新的表单,该代码之前已经输入搜索,已经填充了。


我能够让这些单独工作,但一旦我尝试将它们放在一起,它就会失败。我已经包含了下面的代码。


以下代码打开相应表格的匹配记录。

Hello,

I am having difficulty with Access VBA code. I am using Access 2010 (from work)/2013 (from home). I am creating a database that analyzes the nutritional quality of prepackaged foods for my place of employment, a local food bank.

Users enter a products UPC Code (which I use as the Primary Key). What I would like it to do, is if the product has been previously entered, the Product Form will open. If it is not yet in the database, I would like it to go to a new form with the UPC Code, which was previously entered to search, already populated.

I am able to get these to work individually, but as soon as I try to place them together, it fails. I have included the code that has worked below.

The following code opens a matching record to the appropriate form.

展开 | 选择 | Wrap | 行号

推荐答案

BouwmeesterL,

欢迎来到Bytes.com。


你没有说出失败的本质。那不应该发生的事情是什么,或者应该发生什么不应该发生?


您正在关闭两种不同的形式,如第一个代码块的第3行和第二个代码块的第4行所示。那是你的意思吗?为什么要关闭调用表?


Jim
BouwmeesterL,
Welcome to Bytes.com.

You are not telling anything about the nature of the failure. What is that happens that should not happen, or what fails to happen that should?

You are closing two different forms, as seen in lines 3 of the first code block and line 4 of the second. Is that what you meant to do? Why close the calling form at all?

Jim


我有点困惑,就像Jim一样,但我会先解决问题在First Form上搜索UPC代码。然后,如果找到UPC,打开由UPC过滤的产品表单,如果找不到,则打开产品表单,但转到新记录。所有这一切都可以通过相同的cmdOK_Click程序完成。
I am a bit confused, as Jim is, but I would approach a solution by first searching for the UPC code on your First Form. Then, if the UPC is found, open the Product Form, filtered by the UPC, if it is not found, then open the Product Form, but go to a new record. All this could be done from the same cmdOK_Click procedure.


我为缺乏信息而道歉,并感谢你们两位快速回复。


所以twinnyfo,这正是我遇到的困难。我想让两个代码都使用相同的cmdOK_Click(),但是无法使它们正常工作,这就是为什么我将这两个代码分开的原因。

jimatqi ,对于我的数据库。在主菜单中,您可以选择搜索UPC代码。选择后,将打开搜索表单(frmUPCCodeSearch)。一旦输入并搜索了UPC代码,是的,我希望该表单(frmUPCCodeSearch)关闭以从窗口中删除不需要的表单。


当我合并这两个代码时,它有
A.正确打开产品表单(frmProduct),打开匹配的记录。 (这正是我希望它做的)。


B.当输入当前未输入数据库的产品时,产品表单打开时只显示页眉和页脚。所有其他文本框(个人输入营养质量信息)都丢失了。


今天早上我一直在玩它并相信我可能正在寻找解决方案使用DCount语法


这里是...

I apologize for the lack of information and would like to thank you both for the quick response.

So twinnyfo, that is precisely what I am having difficulty doing. I would like to have both codes work from the same cmdOK_Click(), but have not been able to get them to work correctly which is why I separated the two for this purpose.

jimatqi, for my database. From the Home menu, you have the option to search for a UPC Code. Once that is selected the Search form (frmUPCCodeSearch) opens. Once the UPC Code has been entered and searched for, yes, I would like that form (frmUPCCodeSearch) to close to remove unneeded forms from the window.

When I combine the two codes, it has

A. Correctly open the Product form (frmProduct) with the matching record open. (which is precisely what I would like it to do).

B. When entering a product that is currently not entered in the database the Product form opens with only the header and footer visible. All other text boxes (where an individual enters in the nutritional quality information) is missing.

I have been playing around with it this morning and believe I may am on the way to a solution with a DCount syntax

Here it is...

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


这篇关于文本框搜索问题。如果找到匹配,则显示表格。如果没有,请添加新内容。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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