访问连续子窗体上的编辑记录按钮。

huangapple go评论55阅读模式
英文:

Access edit record button on continuous subform

问题

在Access中,我有一个表单,其中有一个子表单,就像屏幕截图中所示(浅紫色是主表单,深蓝色是子表单标题)。

子表单是一个连续表单。我已经在子表单中添加了2个图像,并想根据行ID编辑记录。

在图像的OnClick事件中,我尝试添加一个消息框来显示以下值:

Me.ID

或者

Me.CurrentRecord

但它们始终显示所有行的相同值。

点击编辑图像将打开一个无绑定表单,因此在表单的OpenArgs中,我需要选定的ID,并将根据选定的ID填充无绑定的编辑表单。

如何获取在连续子表单中记录的按下图像的ID?

英文:

I have a form in Access and there is a subform in it as in the screenshot (light purple is main form, dark blue is subform header).

Subform is a continuous form. I have added 2 images to the subform and want to edit a record based on the row ID.

访问连续子窗体上的编辑记录按钮。

OnClick event of the image, I tried to add a message box to show the values of

Me.ID

or

Me.CurrentRecord

but they both always show the same value for all the rows.

The edit image click will open an Unbound form so in the OpenArgs of the Form I need the Id that is selected and will populate the Unbound Edit form based on the selected ID.

How can I get the pressed image Id of the record in the Contious subform ?

答案1

得分: 1

点击详细部分背景会选择你点击的记录,但点击图像则不会。因此,仅仅点击图像不会改变记录选择,你会始终看到先前选择的记录的数据。

在开发/调试时,你应该在子窗体中启用RecordSelectors,以了解发生了什么。

你需要一个实际的按钮来实现一键完成两个操作:选择记录+执行操作。

解决方案1:使用一个普通按钮,并将图像设置为按钮图像。

解决方案2:在图像前面放置一个透明按钮。

在这两种情况下,将你的代码移到按钮单击事件中。

英文:

While clicking on the detail section background does select the record where you clicked, clicking on an image doesn't.
So just clicking on the image won't change the record selection, and you always see the data of the previously selected record.

While developing / debugging, you should turn on RecordSelectors in the subform, to see what is going on.

You need an actual button to achieve both in one click: select record + do action.

Solution 1: use a normal button with your image as button image.

Solution 2: put a transparent button in front of the image.

In both cases, move your code to the button click event.

huangapple
  • 本文由 发表于 2023年6月13日 18:27:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76463942.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定