在连续表单上创建删除按钮时出现问题 [英] Problem creating a delete button on a continuous form

查看:88
本文介绍了在连续表单上创建删除按钮时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,


我已经使用DoCmd.RunCommand acCmdDeleteRecord在每行上构建了一个带有删除按钮的连续表单。 (有更好的方法吗?)

现在的问题是,当我点击特定行上的按钮时,行没有被选中,除非我点击行的背景或其中一个字段。

因此,不删除与该按钮关联的行,而是删除所选的最后一行(在单击之前)。


如何使这个删除按钮工作?


注意:我没有使用命令按钮控件而是图像控件(因为我想要一个X形按钮悬停和鼠标按下效果)。

Hey,

I''ve built a continuous form with a delete button on each row using DoCmd.RunCommand acCmdDeleteRecord. (Is there a better way?)
Now the problem is that when I click on a button on a specific row, the row isn''t selected, unless I click on the background of the row or one of its fields.
So instead of deleting the row that is associated with the button, the last row that was selected (before the click) is deleted.

How can I make this delete button work?

Note: I''m not using a command button control but an image control (because I wanted to have an X shaped button with a hover and mouse down effects).

推荐答案

你可以在名为DeleteRecord的表中添加一个复选框字段。


显示表单上每个记录中的复选框,允许用户检查删除,然后只需在表单末尾有一个删除按钮,或者将代码保存/关闭在表单上,​​删除所有记录[DeleteRecord] = 1。 br />
You could add a checkbox field to the table called DeleteRecord.

Show the checkbox in each record on the form and allow the user to check for delete then just have a delete button on the end of the form or put code in save/close on the form to delete all records with [DeleteRecord] = 1.


嘿,


我已经使用DoCmd.RunCommand acCmdDeleteRecord在每行上构建了一个带有删除按钮的连续表单。 (有更好的方法吗?)

现在的问题是,当我点击特定行上的按钮时,行没有被选中,除非我点击行的背景或其中一个字段。

因此,不删除与该按钮关联的行,而是删除所选的最后一行(在单击之前)。


如何使这个删除按钮工作?


注意:我没有使用命令按钮控件而是图像控件(因为我想要一个X形按钮悬停和鼠标按下效果)。
Hey,

I''ve built a continuous form with a delete button on each row using DoCmd.RunCommand acCmdDeleteRecord. (Is there a better way?)
Now the problem is that when I click on a button on a specific row, the row isn''t selected, unless I click on the background of the row or one of its fields.
So instead of deleting the row that is associated with the button, the last row that was selected (before the click) is deleted.

How can I make this delete button work?

Note: I''m not using a command button control but an image control (because I wanted to have an X shaped button with a hover and mouse down effects).


好的我还有一个建议:


使用下面的代码点击进行删除当前记录/


Dim rst记录集


设置rst = Me.RecordsetClone

rst.Delete

rst.Close

rst.Requery


:)
Ok I have also a suggestion:

Use the folling code On click to do delete the current record/

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.Delete
rst.Close
rst.Requery

:)



好​​的我还有一个建议:


使用下拉代码点击删除当前记录/

Dim rst作为记录集


设置rst = Me.RecordsetClone

rst.Delete

rst.Close

rst.Requery


:)
Ok I have also a suggestion:

Use the folling code On click to do delete the current record/

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.Delete
rst.Close
rst.Requery

:)



我认为你应该添加rst.update删除后,因为该方法只标记该删除记录,并且在使用更新方法后实际删除。


但是我没看到它如何调用删除访问按钮,其他没有内置删除对话框弹出 - 我想要的行为。


关于使用复选框标记记录,并有一个主删除按钮的建议 - 我不喜欢这样做,因为连续表单是作为子表单嵌入的,所以我想简化与用户的交互到最小化。


是有没有办法删除每行按钮的特定记录,没有选择行的问题?

I think you should add "rst.update" after the delete, because that method only marks that record for deletion, and is actually deleted after using the update method.

But I don''t see how it deffer from calling the delete button of access, other then not having the built in delete dialog popping up - a behavior i want.

About the suggestion to mark the record using check boxes, and having a main delete button - I prefer not to do it this way, because the continuous form is embedded as a sub-form, and so I want to simplify the interaction with the user to a minimal.

Is there a way to delete a specific record with a button for each row, without the problem of not selecting the row?


这篇关于在连续表单上创建删除按钮时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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