如何在“仅添加”中打开表单模式 [英] How to open a form in "add-only" mode

查看:71
本文介绍了如何在“仅添加”中打开表单模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一个单独的表单来向我的数据库添加记录(这样我就可以锁定主ID字段并防止用户意外更改它)。我已经能够创建这个表单,并在我的主窗体上打开一个按钮,但是我还没想出如何在仍然打开的主窗体中创建新记录:我必须关闭在我成功搜索并找到新添加的记录之前,重新打开它。


我该怎么做?

I want to have a separate form for adding records to my database (so that I can lock the main ID field and prevent users'' accidentally changing it). I''ve been able to create this form, and put a button on my main form that opens it, but I haven''t figured out how to make the new record available in the still-open main form: I have to close the main form and re-open it before I can successfully search for and find the newly-added record.

How do I do this?

推荐答案

您好


您需要在关闭之前/期间从AddOnly表单中重新查询MainForm。这可以用这种语法完成


表格(MainFormName)。Requery


此代码可用于AfterUpdate,Unload或者关闭''AddOnly'表单的事件。


一个提示,如果''AddOnly''表单可以打开/使用''MainForm''关闭,那么在尝试Requery之前,你需要检查它是否打开,即

Hi

You need to requery the ''MainForm'' from the ''AddOnly'' form before/during closing it. This can be done with this syntax

Forms("MainFormName").Requery

This code can be used in the AfterUpdate, Unload or Close Event of the ''AddOnly'' form.

One tip, if the ''AddOnly'' form can be open/used with the ''MainForm'' closed, then you will need to check that it is open before trying to Requery, ie.

展开 | 选择 | Wrap | 行号


谢谢,迈克!这几乎就是整件事!但是,我确实有一个表单集合,我不知道如何遍历该集合以重新查询每个表单。


以下是填充该表单的代码集合:

Thanks, Mike! This is almost the entire thing! I do, however, have a Collection of Forms, and I don''t know how to iterate through that collection in order to requery each one.

Here is the code that populates the collection:

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


其他人对此迭代问题有任何想法吗?
Anyone else have any ideas about this iteration problem?


这篇关于如何在“仅添加”中打开表单模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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