如何保存旧记录? [英] How do I save over an old record??

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

问题描述

您好,


我想要做的是我有一个表单设置,您可以在其中输入3种类型的信息,名称,错误代码和数字。我想要做的是当你输入记录然后点击保存按钮时,它会查看保存到的表,并查明是否已有匹配的记录,如果有匹配的记录提示用户,如果他们我想保存一下。现在我有这种工作,但我遇到的问题是,当我去保存它保存在旧记录,但对于一些,因为它保存在旧的,它创建一个新的。所以我最终得到了两个记录,如果我改变了一些东西,我只是为了保存新记录,而不是保存旧记录,任何帮助都会很棒。


这里是我正在使用的代码


我也在Forms BeforeUpdate活动中有这个



感谢帮助

Hello,

what i am trying to do is I have a form set up where you enter in 3 types of information a name, errcode and a number. What I want to do is is when you enter in the record and then hit the save button it looks at the table that its saving to and finds out if there is already a matching record, if there is a matching record prompt the user if they would like to save over the record. Now i have this sort of working but the problem im having is either when I go to save it saves over the old record but for some as it saves over the old one it creates a new one. So I end up with two records or the other if I change some things I just get it to save new records and not save over the old one any help would be great.

here is the code im working with

also i have this in the Forms BeforeUpdate event


appreciate the help

展开 | 选择 | Wrap | 行号

推荐答案

它没有''好像这段代码会覆盖任何东西。使用''addnew''只需添加一条新记录。


我想要的是UPDATE声明。或者你可以在你的记录集上设置一个动态光标并以这种方式更新值。


另一个建议是使用具有主键的ado select语句而不是使用DCount在里面。计算该结果中的记录数(或处理错误,因为如果我没记错的话,这就是ado所做的事情)那么你将不得不使用该主键来删除记录。然后你的addnew或INSERT INTO可能是一个更好的路线
it doesn''t appear as though this code overwrites anything. using ''addnew'' simply adds a new record.

What you are looking for is an UPDATE statement I think. OR you may be able to set a dynamic cursor on your recordset and update the values that way.

Another suggestion is instead of using DCount, fire an ado select statement which has the primary key in it. count the # of records in that result (or handle the error because that is what ado does when it has nothing if I remember correctly) then you''ll have to use that primary key to delete the record. THEN do your addnew or INSERT INTO may be a better route


你好Yarbough40,


你是对的,这个代码不会覆盖任何东西。我试图弄清楚如何覆盖它。每次我尝试更改addnew部分更新或覆盖我只是得到错误。


你能告诉我一个例子或链接到一个如何做你正在谈论的事情的例子吗?


感谢您的帮助! :D
Hi Yarbough40,

you are right about this code does not overwrite anything. Im trying to figure out how to make it overwrite. Everytime I try to change the addnew part to update or overwrite i just get errors back.

Could you show me an example or a link to an example of how to do what you are talking about??

appreciate the help! :D


..如果一切正常,那么你唯一的问题就是rst.addnew它应该是rst.edit!〜)
..if everything else work then your only problem is the rst.addnew it should be rst.edit!~)


这篇关于如何保存旧记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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