Access 2007子窗体充当剪贴板,而不是向子窗体表添加新行 [英] Access 2007 Subform acting as clipboard, not adding new row to subform table

查看:58
本文介绍了Access 2007子窗体充当剪贴板,而不是向子窗体表添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Access 2007.我有一个表单,其中包含要复制到子表单的字段。我有一个ADD按钮,可以将数据粘贴到子窗体,因此子窗体充当剪贴板。我可以让它添加一行,但是在对子表单进行一次输入后不向​​子表格添加新行。


这是我尝试过的一些代码:

I am using Access 2007. I have a form with fields that I want to copy to a subform. I nave an ADD button that can sopy the data to the subform, so the subform is acting as a clipboard. I can get it to add a row, but not add a new row to subform table after doing one entry into the subform.

Here is some code I have tried:

展开 | 选择 | Wrap | 行号

推荐答案

使用UI执行此类操作可能就像纸牌屋。很难建立甚至是难以维护。


我建议创建一个方法将记录插入子表格/表格(GiftList),然后从主表格/表格调用方法(GiftRecipient)。您可以创建一个类似于此的函数:
Using the UI to do something like this can be like a house of cards. Tricky to build and even trickery to maintain.

I would recommend creating a Method to insert records into your Sub Form/Table (GiftList), then call the Method from the Main Form/Table (GiftRecipient). You could create a Function similar to this:
展开 | 选择 | Wrap | 行号


谢谢jforbes,


这是一些很棒的代码。我是一名工程师,而不是一名程序员,但也许我可以学习。你所拥有的东西似乎有一些错别字,但这很容易理解。我猜你没有从你自己的测试代码中复制和粘贴。除了尝试运行SQL语句时的错误外,它似乎都可以正常工作。以下是尝试运行SQL时sSQL变量的示例:

Thank you jforbes,

This is some awesome looking code. I''m a little more an engineer than a coder, but maybe I can learn. There seem to be some typos in what you had, but that''s easy to understand. I''m guessing you weren''t copying and pasting from your own test code. It all seems to work OK, except for an error when trying to run the SQL statement. Here is an example of what the sSQL variable looks like when trying to run the SQL:

展开 | 选择 | Wrap | 行号


你好jforbes,


我想我发现了错误。当字段是数据库表中的字符串时,变量被定义为整数。我解决了这个问题。另外一个控制名称不匹配,但现在不是问题。


这里的事情变得有点搞笑了。它把它添加到表中。然而,似乎并没有在子表单中显示它。一旦运行查询,它就会清除显示在子窗体中的条目。至少那是它的样子。当我打开桌子时,它至少会显示在表格中。如何让子窗体显示已添加的表条目?我的子表单有什么问题吗?


谢谢
Hello jforbes,

I think I found what the error was. A variable was defined as an integer, when the field was a string in the DB table. I got that fixed. Plus a control name was not matching, but that''s not a problem now.

Here''s where things get a little funny. It added it to the table fine. Yet it doesn''t seem to show it in the subform. It clears out the entry from displaying in the subform as soon as the query is run. At least that''s what it looks like. It at least shows up in the Table when I go to just open the table. What can I do to get the subform to display the table entries that have been added? Do I have something set wrong with my subform?

Thank You


这篇关于Access 2007子窗体充当剪贴板,而不是向子窗体表添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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