自动填充表单 [英] Auto populate form

查看:90
本文介绍了自动填充表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表格,该表格要求培训参与者提供基本的人口统计信息,以及参与者参与的所有培训的信息。人口统计信息收集在一个表格中,培训信息写入单独的表格使用子表单。这两个表有一对多的关系。 SSN是两者之间的通用标识符。


我已经在表单上添加了一个搜索框,以便用户可以搜索他们尝试输入的SSN是否已存在于数据库。但是如果他们不这样做并且刚开始进入SSN,我希望用户收到他们尝试输入的SSN已经存在的通知,然后该表单上的SSN信息会自动填充。


目前,我使用的代码通知用户他们输入的SSN已经存在,并填充SSN和培训信息。但是,它不会填写参与者姓名和其他人口统计信息。事实上,在人口统计表中创建了一个重复记录。


这是我正在使用的代码,它是我在网上找到的各种建议的合并。任何关于我做错的提示/指导都将不胜感激。


__________________________________________________ ________________

展开 | 选择 | 换行 | 行号

解决方案

您好,我认为问题在于您使用创建重复记录而不是移动到现有记录的信息来填充绑定控件。


查看本教程,解释在表单上搜索。
以编程方式搜索记录


如果您正在寻找,请告诉我!


< blockquote> SSN是您的主键吗?在表级,您是否设置它以确保没有输入重复项?


通常情况下,您将使用代码转到特定记录(或将表单过滤到特定记录而不是用特定数据填充控件。


数据库正在按照你告诉它对你的代码执行的操作:即它正在创建另一条记录,因为你告诉它这样做!然而,这并不是你想要的。


看看这个教程,我认为它更接近你想要做的事情:在表单上过滤示例


如果您继续遇到问题,请发布回到这里,我们会尽力帮助你! (将来请将代码包装在代码标签中...选择/突出显示代码,转到消息窗口的顶部,然后单击#按钮。编辑第一个[code]标签,以获取vba代码:[code = vb]这只是让它更容易阅读:-)


问候,

Scott


和Jared一起去首先是解决方案!他比我更聪明:-)(也更快,因为他打败了我的回复......一定是在同一时间再次张贴:-)


此致,

Scott


I have created a form that requests basic demographic information on a training participant as well as information on all the training the participant has taken part in. The demographic information is collected in one table and the training information is written to a separate table using a subform. The two tables have a one to many relationship. The SSN is the common identifier between the two.

I have already incorporated a search box on the form so the user may search to see if the SSN they are trying to enter already exists in the database. But in case they do not do that and just begin to enter the SSN, I would like the user to receive notification that the SSN they are trying to enter already exists and then the information for that SSN be automatically populated on the form.

Currently, the code I am using notifies the user the SSN they have entered already exists and it populates the SSN and the training information. However, it does not fill in the participants name and other demographic information. In fact, a duplicate record is created in the demographic table.

Here is the code I am using, which is an amalgamation of various suggestions I have found on the web. Any hints/guidance on what I am doing wrong would be greatly appreciated.

__________________________________________________ ________________

Expand|Select|Wrap|Line Numbers

解决方案

Hi there, I believe the problem is that you''re filling the bound controls with information which is creating a duplicate record rather than moving to the existing record.

Have a look at this tutorial that explains searching on a form.
Programmatically Searching for a Record

Let me know if this is what you''re looking for!


Is the SSN your primary key? At the table level, are you setting it to make sure there are no duplicates entered?

Normally speaking you would use code to go to a specific record (or filter your form to a specific record) rather than populate the controls with specific data.

The database is doing exactly what you are telling it to do with your code: i.e. it''s creating another record because you are telling it to do so! However, that''s not quite what you want.

Have a look at this tutorial, I think it''s closer to what you want to do: Example Filtering on a Form

If you continue having problems, post back here and we''ll do our best to help you out! (in the future please wrap your code in the code tags... Select/highlight the code, go to the top of your message window and click the # button. Edit the first [code] tag to this for vba code: [code=vb] this just makes it easier to read :-)

Regards,
Scott


Go with Jared''s solution first! He''s smarter than I am :-) (and faster too, as he beat me to the reply... must have been posting at the same time again :-)

Regards,
Scott


这篇关于自动填充表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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