使用“条件”保存记录 [英] Saving Record with "Conditions"

查看:55
本文介绍了使用“条件”保存记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows XP和Access 2003.我搜索了我的巨大书籍&这里的问题,并找到一些可能的项目帮助,但仍然不确定。我仍然熟悉Access。我知道有表达式,但是它们需要被表达的顺序和方式仍在进行中。


我正在寻找帮助创建一些代码/表达式。数据库总结如下:


1.该表格可供大约10-15人使用。


2.我想要它们在必填字段中输入信息,并在数据库关闭之前没有输入所需的所有信息时让数据库通知它们。 (目前,当您尝试保存/关闭表单时,它不会警告信息将丢失。)


3.需要14个字段。其中7个需要数据输入,其他7个是自动填充的,或者是下拉列表。


我尝试了几种不同的策略来显示哪些字段是必需的,但它们挂断了并且不允许我去下一个字段,因此不得不关闭数据库并重新开始。我希望这能成为一次性交易。填写信息,如果字段为空/空(不确定哪个是合适的),则会弹出消息框,指示字段留空(我可以输入自定义消息,告知要查看哪些字段),然后可以进行调整。正确填写所有字段后,表单将保存。


我认为,如果他们试图X,则表示警告也是有帮助的。在没有保存的情况下退出数据库,它们将丢失所有数据。也可以将其设置为确定 - 返回并输入信息。或关闭并且不保存消息框中的选项。


我只是不希望表单关闭而不是保存,特别是当其他字段填充了描述等时,我的同事来了火把和我在一起音叉。


我希望这不会像看上去那样令人困惑。


感谢您的帮助。


Kari

I am using Windows XP and Access 2003. I have searched through my HUGE book & the questions here, and found some items that "might" help, but unsure still. I am still getting versed on Access. I know there are expressions, however the order and manner in which they need to be phrased is still a work in progress.

I am looking for help creating some code/expressions. The database is summarized below:

1. The form is open for data entry to about 10-15 people.

2. I want them to enter information in required fields, AND have the database inform them when they have not entered all the information required BEFORE the database closes. (Currently when you try to "Save/Close" the form, it doesn''t warn that the information will be lost.)

3. There are 14 fields required. Of those 7 require data entry, the other 7 are auto populated, or are the pull down list.

I have tried several different tactics to show which fields are required, but they hang up and don''t allow me to go to the next field, thus having to shut down the database and starting again. I would like this to be able to be a one shot deal. The information is filled out, if a field is Null/Empty (not sure which is appropriate), then the Message Box would pop up indicating a field was left blank (I can put in a custom message telling which fields to look at), and then the adjustment can be made. Once all fields are filled properly, the form will save.

I think it would also be helpful to indicate a warning that if they try to "X" out of the database without saving, they will lose all data. That can also be placed as an "OK - go back and enter info" or "Close and do not save" option in the Message Box.

I just don''t want the form to close and not save, especially when other fields have populated with descriptions, etc. and my co-workers come at me with torches & pitch forks.

I hope this is not as confusing as it appears.

Thanks for all the help.

Kari

推荐答案

@Marilyth


Hello Kari。以下是我个人在主表单上使用的一些代码,用于检查10个必填字段中是否存在数据。此代码包含在Form的BeforeUpdate()事件中。它检查逻辑序列中每个字段中是否存在数据。如果在字段中找不到数据,则会出现字段特定和描述性消息框,BeforeUpdate()事件被取消,焦点转移到字段,如果字段是组合框,则它被删除。如果数据存在于所有10个字段中,则记录将被保存。希望这会有所帮助。
@Marilyth
Hello Kari. Here is some code that I personally use on my Main Form to check for the existence of Data in 10 Required Fields. This code is contained within the BeforeUpdate() Event of the Form. It checks for the existence of Data in each of the Fields in their Logical Sequence. If Data is not found in a Field, a Field specific and descriptive Message Box appears, the BeforeUpdate() Event is Cancelled, Focus shifts to the Field, and if the Field is a Combo Box it is dropped. Should Data exist in all 10 Fields, then the Record is Saved. Hope this helps.
展开 | 选择 < span class =codeDivider> | Wrap | 行号


如果您不需要为显示的消息框设置特定文本可以为每个需要数据的控件设置tag属性,然后循环访问控件来检查它们。在以下示例中,我将标记设置为required。没有每个必需文本控件的引号。

If you didn''t need to have a specific text for the message box being displayed you could just set the tag property for each control requiring data and then loop through the controls checking for them. In the following example I would set the tag to "required" without the quotes for each required text control.

展开 | 选择 | Wrap | 行号


@DonRayner


哎呀我犯了一个错误,你需要在第6行和第6行之间添加另一行。 7.
@DonRayner
Oops I made a mistake you would need to add another line between lines 6 & 7.
展开 | 选择 | Wrap | 行号


这篇关于使用“条件”保存记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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