在表中创建新行 [英] Create new row in table

查看:66
本文介绍了在表中创建新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个编辑 form = fEditLoc用于子表单中的行= subfShowLoc。表单打开后,我希望能够在table = tLoc中创建一条新记录,然后我将对其进行编辑。


或者换句话说,我想编辑一个记录,然后执行另存为到一个新的记录。看起来很简单,但是当我将表单移动到NewRecord位置时,我无法将数据保存在所有字段中。那我该怎么做呢?

I want to have an "Edit" form=fEditLoc for rows in a subform=subfShowLoc. Once the form opens, I want to be able to create a new record in the table=tLoc which I will then edit.

Or to put it another way, I want to edit a record, and then do a "Save As" to a new record. Seems simple, but I can''t keep the data in all the fields when I move the form to the NewRecord position. So how do I do this?

推荐答案

@OldBirdman


Hello OldBirdman,试试这个,看看有什么发生:
@OldBirdman
Hello OldBirdman, try this out and see what happens:
展开 | 选择 | Wrap | 行号


谢谢。这些工具将适用于此。


只是好奇,但我认为在某些地方我会尽可能避免使用DoMenuItem。物品的相对位置可能会发生变化,或者其他什么。这是我应该关注的事情吗?
Thank you. These tools will work for this.

Just curious, but I think somewhere I read that DoMenuItem was to be avoided if possible. The relative position of the items may change, or something. Is this something I should be concerned about?


我想我回答得太快了。我想要我的另存为保持原始记录不变,如果我们在NotePad中编辑文件,进行一些更改,并决定创建一个新文件。我们SaveAs并继续编辑。最后,原始文件保持不变,新文件包含SaveAs之前和之后的更改(假设在关闭之前最终保存)。


第2行在帖子#2中建议的代码保存记录。如果我在进行任何更改之前选择,则在表单变脏时未选中。


我可以使用每个控件的OldValue属性保存所有字段。然后我选择记录,允许Access保存更改的记录。在FormClose上,我将不得不移回原始记录,并恢复原始值并保存。程序必须是递归的,因为我可能想要创建一系列记录,每个记录与前一个记录略有不同。


1.致电表格

2.进行更改,例如txtField = Test 1

3.另存为创建一个新记录

4将1改为2,避免输入单词Test。和任何其他常见数据字段

5.另存为创造一个新的纪录

6. ...根据需要重复


这看起来很笨拙,粗鲁和捣蛋。像我的大多数代码一样,我很害怕。
I think I replied too quickly. I would like my "Save As" to leave the original record unchanged, as happens if we edit a file in say NotePad, make some changes, and decide to create a new file. We SaveAs and continure editing. At the end, the original file is unchanged, and the new file has the changes from before the SaveAs and after it (presuming a final Save before closing).

Line #2 of the code suggested in Post #2 saves the record. If I select before any changes are made, it is un-selected when form becomes dirty.

I could save all the fields using each control''s OldValue property. Then I select the record, allowing Access to save the changed record. On FormClose, I would have to move back to the original record, and restore the original values and save it. Procedures would have to be recursive, because I might want to create a series of records, each a slight change from the previous one.

1. Call form
2. Make changes, say txtField = Test 1
3. "Save As" to create a new record
4 Change the 1 to a 2, avoiding typing the word "Test" and any other common data fields
5. "Save As" to create a new record
6. ... Repeat as necessary

This seems clumsy, crude, and amaturish. Like most of my code, I''m afraid.


这篇关于在表中创建新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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